Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59819 - sandbox/stm/boost/stm
From: justin_at_[hidden]
Date: 2010-02-21 14:13:52


Author: jgottschlich
Date: 2010-02-21 14:13:51 EST (Sun, 21 Feb 2010)
New Revision: 59819
URL: http://svn.boost.org/trac/boost/changeset/59819

Log:
blah
Text files modified:
   sandbox/stm/boost/stm/transaction.hpp | 101 ++++++++++++++++++++++++++++++++++++++-
   1 files changed, 96 insertions(+), 5 deletions(-)

Modified: sandbox/stm/boost/stm/transaction.hpp
==============================================================================
--- sandbox/stm/boost/stm/transaction.hpp (original)
+++ sandbox/stm/boost/stm/transaction.hpp 2010-02-21 14:13:51 EST (Sun, 21 Feb 2010)
@@ -108,6 +108,8 @@
 #endif
    typedef std::map<size_t, ReadContainer*> ThreadReadContainer;
 
+ typedef std::multimap<base_transaction_object*, base_transaction_object*> MapOfTxObjects;
+
 #ifdef MAP_WRITE_CONTAINER
    typedef std::map<base_transaction_object*, base_transaction_object*> WriteContainer;
 #else
@@ -240,7 +242,7 @@
       else return directLateWriteReadConflict_ = true;
    }
 
- inline static std::string consistency_checking_string()
+ inline static std::string conflict_detection_string()
    {
       if (validating()) return "val";
       else return "inval";
@@ -341,7 +343,85 @@
    static int pthread_trylock(Mutex *lock);
    static int pthread_unlock(Mutex *lock);
 
+ //##########################################################################
+ // begin transaction::bind() implementation
+ //##########################################################################
+
+ //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ void if_bound_perform_subreads(base_transaction_object* lhs)
+ {
+ lock_general_access();
+
+ MapOfTxObjects::iterator i = threadBoundObjects_.find(lhs);
+
+ if (i != threadBoundObjects_.end())
+ {
+ this->read(*(i->second));
+
+ for (++i; i != threadBoundObjects_.end(); ++i)
+ {
+ if (i->first != lhs) break;
+ this->read(*(i->second));
+ }
+ }
+
+ unlock_general_access();
+ }
+
+ //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ static void bind(base_transaction_object * lhs,
+ base_transaction_object * rhs)
+ {
+ //-----------------------------------------------------------------------
+ // because bind might be called before the TM is initialized (due to
+ // global space allocation), we need to force a call to initialiaze()
+ // so our general lock will be initialized, if initialized_ is false
+ //-----------------------------------------------------------------------
+ if (!initialized_) initialize();
 
+ lock_general_access();
+ threadBoundObjects_.insert(MapOfTxObjects::value_type(lhs, rhs));
+ unlock_general_access();
+ }
+
+ //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ static void unbind(base_transaction_object * lhs)
+ {
+ //-----------------------------------------------------------------------
+ // because bind might be called before the TM is initialized (due to
+ // global space allocation), we need to force a call to initialiaze()
+ // so our general lock will be initialized, if initialized_ is false
+ //-----------------------------------------------------------------------
+ if (!initialized_) initialize();
+
+ lock_general_access();
+
+ unlock_general_access();
+ }
+
+ //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ static void unbind(base_transaction_object * lhs,
+ base_transaction_object * rhs)
+ {
+ //-----------------------------------------------------------------------
+ // because bind might be called before the TM is initialized (due to
+ // global space allocation), we need to force a call to initialiaze()
+ // so our general lock will be initialized, if initialized_ is false
+ //-----------------------------------------------------------------------
+ if (!initialized_) initialize();
+
+ lock_general_access();
+
+ unlock_general_access();
+ }
+
+ //##########################################################################
+ // end transaction::bind() implementation
+ //##########################################################################
 
    //--------------------------------------------------------------------------
 #if PERFORMING_LATM
@@ -842,6 +922,11 @@
             //guard.unlock();
 
             ++reads_;
+
+ // before leaving, we need to verify this object isn't bound
+ // to subobjects
+ if_bound_perform_subreads(readMem->second);
+
             return *static_cast<T*>(readMem->second);
          }
 
@@ -1289,7 +1374,7 @@
    static transaction_bookkeeping bookkeeping_;
    static base_contention_manager *cm_;
 
-
+ static MapOfTxObjects threadBoundObjects_;
 
 #ifndef USE_SINGLE_THREAD_CONTEXT_MAP
     static ThreadWriteContainer threadWriteLists_;
@@ -1507,9 +1592,15 @@
     TransactionsStack& transactionsRef_;
    public:
     inline TransactionsStack& transactions() {return transactionsRef_;}
- inline static TransactionsStack &transactions(thread_id_t id) {
- light_auto_lock auto_general_lock_(general_lock());
- return *threadTransactionsStack_.find(id)->second;
+ inline static TransactionsStack &transactions(thread_id_t id,
+ bool const &alreadyHasGeneralLock = false) {
+
+ if (!alreadyHasGeneralLock)
+ {
+ light_auto_lock auto_general_lock_(general_lock());
+ return *threadTransactionsStack_.find(id)->second;
+ }
+ else return *threadTransactionsStack_.find(id)->second;
     }
     private:
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk