Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57497 - in sandbox/stm/branches/vbe: boost/stm boost/stm/detail boost/stm/latm boost/stm/synch boost/synchro/poly libs/stm/test
From: vicente.botet_at_[hidden]
Date: 2009-11-08 18:38:35


Author: viboes
Date: 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
New Revision: 57497
URL: http://svn.boost.org/trac/boost/changeset/57497

Log:
TBoost.STM vbe: BOOST_STM_LATM_GENERIC works now

Text files modified:
   sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 2
   sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp | 14 +++++---
   sandbox/stm/branches/vbe/boost/stm/latm/datatypes.hpp | 7 ++-
   sandbox/stm/branches/vbe/boost/stm/synch.hpp | 2
   sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp | 41 ++++++++++++++-----------
   sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp | 7 ++-
   sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp | 63 +++++++++++++++++++++++++++++++++------
   sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp | 23 +++++++------
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 18 +++++++---
   sandbox/stm/branches/vbe/boost/synchro/poly/lock.hpp | 1
   sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp | 13 +++----
   sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp | 15 +++-----
   sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp | 12 +++----
   sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp | 20 ++++--------
   sandbox/stm/branches/vbe/libs/stm/test/lotExample.cpp | 24 ++++----------
   sandbox/stm/branches/vbe/libs/stm/test/nestedTxs.cpp | 19 +++--------
   sandbox/stm/branches/vbe/libs/stm/test/testHashMapWithLocks.h | 2
   sandbox/stm/branches/vbe/libs/stm/test/testLL_latm.h | 15 +++++----
   sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.h | 15 +++++----
   sandbox/stm/branches/vbe/libs/stm/test/txLinearLock.cpp | 12 +++---
   sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp | 17 ++++------
   sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.h | 16 +++++----
   22 files changed, 195 insertions(+), 163 deletions(-)

Modified: sandbox/stm/branches/vbe/boost/stm/detail/config.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/config.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/config.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -134,7 +134,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Define BOOST_STM_LATM_GENERIC when you want Boost.STM to manage with arbitrary mutex
 
-//#define BOOST_STM_LATM_GENERIC 1
+#define BOOST_STM_LATM_GENERIC 1
 
 ///////////////////////////////////////////////////////////////////////////////
 #endif // BOOST_STM_DETAIL_CONFIG_H

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -230,10 +230,11 @@
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 
-inline void boost::stm::transaction::tm_lock_conflict(latm::mutex_type* inLock)
+template <typename MP>
+inline void boost::stm::transaction::tm_lock_conflict(MP* inLock)
 {
 #if 1
- latm::instance().tm_lock_conflict(inLock);
+ latm::instance().tm_lock_conflict(inLock->the_poly_lock());
 #else
    if (!latm::instance().doing_tm_lock_protection()) return;
 
@@ -279,7 +280,8 @@
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
-inline void boost::stm::transaction::add_tx_conflicting_lock(latm::mutex_type* inLock)
+template <typename MP>
+inline void boost::stm::transaction::add_tx_conflicting_lock(MP* inLock)
 {
    if (!latm::instance().doing_tx_lock_protection()) return;
 
@@ -288,8 +290,8 @@
       synchro::lock_guard<Mutex> autolock_g(*general_lock());
       synchro::lock_guard<Mutex> autolock_i(*inflight_lock());
 
- if (get_tx_conflicting_locks().find(inLock) != get_tx_conflicting_locks().end()) return;
- get_tx_conflicting_locks().insert(inLock);
+ if (get_tx_conflicting_locks().find(&inLock->the_poly_lock()) != get_tx_conflicting_locks().end()) return;
+ get_tx_conflicting_locks().insert(&inLock->the_poly_lock());
 
       if (irrevocable()) return;
 
@@ -350,7 +352,7 @@
    switch (latm::instance().protection())
    {
    case eFullLatmProtection:
- if (direct_updating()) return dir_fulltry_lock(m, mutex);
+ if (direct_updating()) return dir_full_try_lock(m, mutex);
       else return def_full_try_lock(m, mutex);
    case eTmConflictingLockLatmProtection:
       if (direct_updating()) return dir_tm_try_lock(m, mutex);

Modified: sandbox/stm/branches/vbe/boost/stm/latm/datatypes.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/latm/datatypes.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/latm/datatypes.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -18,15 +18,16 @@
 #include <boost/stm/datatypes.hpp>
 #include <set>
 #include <map>
-#if BOOST_STM_LATM_GENERIC
-#include <boost/stm/synchro/poly/lock.hpp>
+#ifdef BOOST_STM_LATM_GENERIC
+
+#include <boost/synchro/poly/lock.hpp>
 #else
 #include <pthread.h>
 #endif
 
 namespace boost { namespace stm { namespace latm {
     struct static_mode {};
-#if BOOST_STM_LATM_GENERIC
+#ifdef BOOST_STM_LATM_GENERIC
     typedef boost::synchro::poly::exclusive_lock mutex_type;
 #else
     typedef pthread_mutex_t mutex_type;

Modified: sandbox/stm/branches/vbe/boost/stm/synch.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -21,6 +21,6 @@
 #include <boost/stm/synch/synchronized.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
-#endif // TRANSACTION_H
+#endif // BOOST_STM_SYNCH__HPP
 
 

Modified: sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -29,24 +29,23 @@
 #ifdef PERFORMING_LATM
 #include <boost/stm/transaction.hpp>
 #include <boost/stm/latm.hpp>
-#else
+#include <boost/stm/synch/mutex.hpp>
 #endif
 //---------------------------------------------------------------------------
 
 
 //---------------------------------------------------------------------------
 #ifdef PERFORMING_LATM
-#define BOOST_STM_LOCK(a, b) boost::stm::lock(a,b)
-#define BOOST_STM_UNLOCK(a, b) boost::stm::unlock(a, b)
+#define BOOST_STM_LOCK(a) a.lock()
+#define BOOST_STM_UNLOCK(a) a.unlock()
 #else
-#define BOOST_STM_LOCK(a, b) boost::synchro::lock(a)
-#define BOOST_STM_UNLOCK(a, b) boost::synchro::unlock(a)
+#define BOOST_STM_LOCK(a) boost::synchro::lock(a)
+#define BOOST_STM_UNLOCK(a) boost::synchro::unlock(a)
 #endif
 
 //---------------------------------------------------------------------------
 namespace boost { namespace stm {
 
-
 //---------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 class timer_lock_exception : public std::exception
@@ -67,28 +66,34 @@
 //-----------------------------------------------------------------------------
 class auto_lock
 {
+#ifndef BOOST_STM_T_USE_BOOST_MUTEX
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
+#else
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
+#endif
+
 public:
    typedef std::pair<thread_id_t const, latm::mutex_type*> ThreadedLockPair;
    typedef std::multimap<thread_id_t const, latm::mutex_type*> ThreadedLockContainer;
    typedef ThreadedLockContainer::iterator ThreadedLockIter;
 
- auto_lock(latm::mutex_type &mutex) : hasLock_(false), lock_(mutex)
+ auto_lock(mutex_type &mutex) : hasLock_(false), lock_(mutex)
    {
       do_auto_lock();
    }
 
- auto_lock(latm::mutex_type *mutex) : hasLock_(false), lock_(*mutex)
+ auto_lock(mutex_type *mutex) : hasLock_(false), lock_(*mutex)
    {
       do_auto_lock();
    }
 
 
- auto_lock(milliseconds_t timeOut, latm::mutex_type &mutex) : hasLock_(false), lock_(mutex)
+ auto_lock(milliseconds_t timeOut, mutex_type &mutex) : hasLock_(false), lock_(mutex)
    {
       do_timed_auto_lock(timeOut);
    }
 
- auto_lock(milliseconds_t timeOut, latm::mutex_type *mutex) : hasLock_(false), lock_(*mutex)
+ auto_lock(milliseconds_t timeOut, mutex_type *mutex) : hasLock_(false), lock_(*mutex)
    {
       do_timed_auto_lock(timeOut);
    }
@@ -111,14 +116,14 @@
    {
       //lock_ = mutex;
 
- if (thread_has_lock(lock_)) return;
+ if (thread_has_lock(lock_.the_poly_lock())) return;
 
       for (milliseconds_t i = 0; i < timeOut; ++i)
       {
          if (synchro::try_lock(lock_))
          {
             hasLock_ = true;
- insert_into_threaded_lock_map(lock_);
+ insert_into_threaded_lock_map(lock_.the_poly_lock());
             return;
          }
 
@@ -137,12 +142,12 @@
    void do_auto_lock()
    {
       //lock_ = mutex;
- if (thread_has_lock(lock_)) return;
+ if (thread_has_lock(lock_.the_poly_lock())) return;
 
- BOOST_STM_LOCK(lock_, lock_);
+ BOOST_STM_LOCK(lock_);
       hasLock_ = true;
 
- insert_into_threaded_lock_map(lock_);
+ insert_into_threaded_lock_map(lock_.the_poly_lock());
    }
 
    void do_auto_unlock()
@@ -150,8 +155,8 @@
       if (hasLock_)
       {
          hasLock_ = false;
- BOOST_STM_UNLOCK(lock_, lock_);
- remove_thread_has_lock(lock_);
+ BOOST_STM_UNLOCK(lock_);
+ remove_thread_has_lock(lock_.the_poly_lock());
       }
    }
 
@@ -206,7 +211,7 @@
    //auto_lock& operator=(auto_lock const &);
 
    bool hasLock_;
- latm::mutex_type &lock_;
+ mutex_type &lock_;
 };
 
 //---------------------------------------------------------------------------

Modified: sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -47,17 +47,18 @@
     class lock_guard {
     private:
         //Mutex& m;
- stm::exclusive_ref_lock_adapter<Mutex> m;
+ typedef Mutex mutex_type;
+ mutex_type& m;
 
         explicit lock_guard(lock_guard&);
         lock_guard& operator=(lock_guard&);
     public:
- explicit lock_guard(Mutex& m_)
+ explicit lock_guard(mutex_type& m_)
             : m(m_)
         {
             m.lock();
         }
- lock_guard(Mutex& m_, bool cnd, adopt_lock_t)
+ lock_guard(mutex_type& m_, bool cnd, adopt_lock_t)
             : m(m_)
         {}
         ~lock_guard() {

Modified: sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -24,34 +24,76 @@
 
 namespace boost { namespace stm {
 
-template <typename Lockable>
-class exclusive_lock_adapter : public boost::synchro::poly::exclusive_lock
+template <typename Lockable, typename Base=boost::synchro::poly::exclusive_lock
+ , template <class, class> class Poly = boost::synchro::poly::exclusive_ref_lock_adapter >
+class exclusive_lock_adapter;
+
+template <typename Lockable, typename Base, template <class, class> class Poly >
+class exclusive_lock_adapter
 {
 public:
     typedef Lockable lockable_type;
 
     BOOST_COPY_CONSTRUCTOR_DELETE(exclusive_lock_adapter) /*< disable copy construction >*/
     BOOST_COPY_ASSIGNEMENT_DELETE(exclusive_lock_adapter) /*< disable copy asignement >*/
- exclusive_lock_adapter() {}
+ exclusive_lock_adapter()
+ : st_lock_()
+ , dyn_lock_(st_lock_)
+ {}
+
+ ~exclusive_lock_adapter() {}
+
+ void lock() {stm::lock(st_lock_, dyn_lock_);}
+ void unlock() {stm::unlock(st_lock_, dyn_lock_);}
+ bool try_lock() { return stm::try_lock(st_lock_, dyn_lock_);}
+
+ lockable_type& the_lock() { return st_lock_; }
+ boost::synchro::poly::exclusive_lock& the_poly_lock() { return dyn_lock_; }
+protected:
+ mutable lockable_type st_lock_;
+ mutable Poly<lockable_type, Base> dyn_lock_;
+};
+
+template <typename Base, template <class, class> class Poly >
+class exclusive_lock_adapter<pthread_mutex_t, Base, Poly>
+{
+public:
+ typedef pthread_mutex_t lockable_type;
+
+ BOOST_COPY_CONSTRUCTOR_DELETE(exclusive_lock_adapter) /*< disable copy construction >*/
+ BOOST_COPY_ASSIGNEMENT_DELETE(exclusive_lock_adapter) /*< disable copy asignement >*/
+ exclusive_lock_adapter()
+ : st_lock_(PTHREAD_MUTEX_INITIALIZER)
+ , dyn_lock_(st_lock_)
+ {}
     ~exclusive_lock_adapter() {}
 
- void lock() {stm::lock(lock_);}
- void unlock() {stm::unlock(lock_);}
- bool try_lock() { return stm::try_lock(lock_);}
+ void lock() {stm::lock(st_lock_, dyn_lock_);}
+ void unlock() {stm::unlock(st_lock_, dyn_lock_);}
+ bool try_lock() { return stm::try_lock(st_lock_, dyn_lock_);}
 
+ lockable_type& the_lock() { return st_lock_; }
+ boost::synchro::poly::exclusive_lock& the_poly_lock() { return dyn_lock_; }
+
 protected:
- lockable_type* the_lock() { return &lock_; }
- mutable lockable_type lock_;
+ mutable lockable_type st_lock_;
+ mutable Poly<lockable_type, Base> dyn_lock_;
 };
+
+#if 0
 #if BOOST_STM_LATM_GENERIC
 
-template <typename Lockable, typename Base=boost::synchro::poly::exclusive_lock, template <class, class> class Poly = boost::synchro::poly::exclusive_ref_lock_adapter >
+template <typename Lockable, typename Base=boost::synchro::poly::exclusive_lock
+ , template <class, class> class Poly = boost::synchro::poly::exclusive_ref_lock_adapter >
 class exclusive_ref_lock_adapter
 {
 public:
     typedef Lockable lockable_type;
 
- exclusive_ref_lock_adapter(lockable_type& lock): st_lock_(lock), dyn_lock_(lock) {}
+ exclusive_ref_lock_adapter(lockable_type& lock)
+ : st_lock_(lock)
+ , dyn_lock_(lock)
+ {}
     ~exclusive_ref_lock_adapter() {}
 
     void lock() {stm::lock(st_lock_, dyn_lock_);}
@@ -83,6 +125,7 @@
 };
 
 #endif
+#endif
 #if 0
 template <typename Lockable>
 void lock(exclusive_lock_adapter<Lockable>& lock) {transaction::lock(lock, lock);}

Modified: sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -29,8 +29,9 @@
     class unique_lock
     {
     private:
- stm::exclusive_ref_lock_adapter<Mutex> mtx_;
- stm::exclusive_ref_lock_adapter<Mutex>* m;
+ typedef Mutex mutex_type;
+ mutex_type& mtx_;
+ mutex_type* m;
         bool is_locked;
     
         unique_lock(unique_lock&);
@@ -42,30 +43,30 @@
         {}
         #endif
 
- explicit unique_lock(Mutex& m_):
+ explicit unique_lock(mutex_type& m_):
             mtx_(m_),m(&mtx_),is_locked(false)
         {
             lock();
         }
 
- unique_lock(Mutex& m_,adopt_lock_t):
+ unique_lock(mutex_type& m_,adopt_lock_t):
             mtx_(m_),m(&mtx_),is_locked(true)
         {}
- unique_lock(Mutex& m_,defer_lock_t):
+ unique_lock(mutex_type& m_,defer_lock_t):
             mtx_(m_),m(&mtx_),is_locked(false)
         {}
- unique_lock(Mutex& m_,try_to_lock_t):
+ unique_lock(mutex_type& m_,try_to_lock_t):
             mtx_(m_),m(&mtx_),is_locked(false)
         {
             try_lock();
         }
         template<typename TimeDuration>
- unique_lock(Mutex& m_,TimeDuration const& target_time):
+ unique_lock(mutex_type& m_,TimeDuration const& target_time):
             mtx_(m_),m(&mtx_),is_locked(false)
         {
             lock_for(target_time);
         }
- unique_lock(Mutex& m_,system_time const& target_time):
+ unique_lock(mutex_type& m_,system_time const& target_time):
             mtx_(m_),m(&mtx_),is_locked(false)
         {
             lock_until(target_time);
@@ -195,14 +196,14 @@
             return is_locked;
         }
 
- Mutex* mutex() const
+ mutex_type* mutex() const
         {
             return m;
         }
 
- Mutex* release()
+ mutex_type* release()
         {
- Mutex* const res=m;
+ mutex_type* const res=m;
             m=0;
             is_locked=false;
             return res;

Modified: sandbox/stm/branches/vbe/boost/stm/transaction.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/transaction.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/transaction.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -322,11 +322,13 @@
    //--------------------------------------------------------------------------
     #if PERFORMING_LATM
    //--------------------------------------------------------------------------
- inline static void tm_lock_conflict(latm::mutex_type &lock)
+ template <typename MP>
+ inline static void tm_lock_conflict(MP &lock)
    {
       tm_lock_conflict(&lock);
    }
- static void tm_lock_conflict(latm::mutex_type* lock);
+ template <typename MP>
+ static void tm_lock_conflict(MP* lock);
 
    static void clear_tm_conflicting_locks();
    //inline static latm::mutex_set get_tm_conflicting_locks() { return tmConflictingLocks_; }
@@ -337,17 +339,21 @@
     #if USING_TRANSACTION_SPECIFIC_LATM
    void see_if_tx_must_block_due_to_tx_latm();
 
- inline void lock_conflict(latm::mutex_type &lock)
+ template <typename MP>
+ inline void lock_conflict(MP &lock)
    { add_tx_conflicting_lock(&lock); }
 
- inline void lock_conflict(latm::mutex_type* lock)
+ template <typename MP>
+ inline void lock_conflict(MP* lock)
    { add_tx_conflicting_lock(lock); }
 
- inline void add_tx_conflicting_lock(latm::mutex_type &lock)
+ template <typename MP>
+ inline void add_tx_conflicting_lock(MP &lock)
    {
       add_tx_conflicting_lock(&lock);
    }
- void add_tx_conflicting_lock(latm::mutex_type* lock);
+ template <typename MP>
+ void add_tx_conflicting_lock(MP* lock);
 
    void clear_tx_conflicting_locks();
    //latm::mutex_set get_tx_conflicting_locks() { return conflictingMutexRef_; }

Modified: sandbox/stm/branches/vbe/boost/synchro/poly/lock.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/synchro/poly/lock.hpp (original)
+++ sandbox/stm/branches/vbe/boost/synchro/poly/lock.hpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -14,6 +14,7 @@
 #include <boost/chrono/chrono.hpp>
 #include <boost/thread/thread_time.hpp>
 #endif
+
 namespace boost { namespace synchro { namespace poly {
 
 //////////////////////////////////////////////////////////////////////////////

Modified: sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -37,17 +37,16 @@
 #include "main.h"
 
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
+
 static boost::stm::native_trans<int> gInt;
-#ifndef BOOST_STM_T_USE_BOOST_MUTEX
-static pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER;
-#else
-static boost::mutex lock1;
-#endif
+
+static mutex_type lock1;
+
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
 using namespace boost;

Modified: sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -37,20 +37,17 @@
 #include "main.h"
 
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
 static boost::stm::native_trans<int> gInt;
 static boost::stm::native_trans<int> gInt2;
-#ifndef BOOST_STM_T_USE_BOOST_MUTEX
-static pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER;
-//static pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
-#else
-static boost::mutex lock1;
-//static boost::mutex lock2;
-#endif
+
+static mutex_type lock1;
+//static mutex_type lock2;
+
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
 using namespace boost;

Modified: sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -37,18 +37,16 @@
 #include "main.h"
 
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
 static boost::stm::native_trans<int> gInt;
 static boost::stm::native_trans<int> gInt2;
-#ifndef BOOST_STM_T_USE_BOOST_MUTEX
-static pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER;
-#else
-static boost::mutex lock1;
-#endif
+
+static mutex_type lock1;
+
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
 using namespace boost;

Modified: sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -37,22 +37,16 @@
 #include "main.h"
 
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
-#ifndef BOOST_STM_T_USE_BOOST_MUTEX
-static pthread_mutex_t L2 = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t L3 = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t L4 = PTHREAD_MUTEX_INITIALIZER;
-//static pthread_mutex_t L8 = PTHREAD_MUTEX_INITIALIZER;
-#else
-static boost::mutex L2;
-static boost::mutex L3;
-static boost::mutex L4;
-//static boost::mutex L8;
-#endif
+static mutex_type L2;
+static mutex_type L3;
+static mutex_type L4;
+//static mutex_type L8;
+
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
 using namespace boost;

Modified: sandbox/stm/branches/vbe/libs/stm/test/lotExample.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/lotExample.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/lotExample.cpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -37,27 +37,17 @@
 #include "main.h"
 
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
-#ifndef BOOST_STM_T_USE_BOOST_MUTEX
-
-static pthread_mutex_t L1 = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t L2 = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t L3 = PTHREAD_MUTEX_INITIALIZER;
-//static pthread_mutex_t L8 = PTHREAD_MUTEX_INITIALIZER;
-//static pthread_mutex_t L9 = PTHREAD_MUTEX_INITIALIZER;
+static mutex_type L1;
+static mutex_type L2;
+static mutex_type L3;
+//static mutex_type L8;
+//static mutex_type L9;
 
-#else
-static boost::mutex L1;
-static boost::mutex L2;
-static boost::mutex L3;
-//static boost::mutex L8;
-//static boost::mutex L9;
-
-#endif
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
 using namespace boost;

Modified: sandbox/stm/branches/vbe/libs/stm/test/nestedTxs.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/nestedTxs.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/nestedTxs.cpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -35,22 +35,15 @@
 #include <boost/stm/synch.hpp>
 
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
-#ifndef BOOST_STM_T_USE_BOOST_MUTEX
-static pthread_mutex_t L = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t L2 = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t L3 = PTHREAD_MUTEX_INITIALIZER;
-//static pthread_mutex_t L4 = PTHREAD_MUTEX_INITIALIZER;
-#else
-static boost::mutex L;
-static boost::mutex L2;
-static boost::mutex L3;
-//static boost::mutex L4;
-#endif
+static mutex_type L;
+static mutex_type L2;
+static mutex_type L3;
+//static mutex_type L4;
 
 using namespace boost::stm;
 using namespace boost;

Modified: sandbox/stm/branches/vbe/libs/stm/test/testHashMapWithLocks.h
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testHashMapWithLocks.h (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testHashMapWithLocks.h 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -79,7 +79,7 @@
       }
    }
 
- pthread_mutex_t* get_hash_lock(int val) { return buckets_[val].get_list_lock(); }
+ mutex_type* get_hash_lock(int val) { return buckets_[val].get_list_lock(); }
 
 private:
    LATM::LinkedList<T> buckets_[nHashMap::kBuckets2];

Modified: sandbox/stm/branches/vbe/libs/stm/test/testLL_latm.h
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testLL_latm.h (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testLL_latm.h 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -20,10 +20,11 @@
 #include <boost/stm/synch.hpp>
 #include <pthread.h>
 #include <fstream>
+
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -97,15 +98,15 @@
 
    LinkedList()
    {
-#ifndef BOOST_STM_T_USE_BOOST_MUTEX
- pthread_mutex_init (&list_lock_, 0);
-#endif
+//#ifndef BOOST_STM_T_USE_BOOST_MUTEX
+// pthread_mutex_init (&list_lock_, 0);
+//#endif
       head_.value() = T();
    }
 
    ~LinkedList() { quick_clear(); }
 
- pthread_mutex_t* get_list_lock() { return &list_lock_; }
+ mutex_type* get_list_lock() { return &list_lock_; }
 
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
@@ -536,7 +537,7 @@
 public:
 
    list_node<T> head_;
- pthread_mutex_t list_lock_;
+ mutex_type list_lock_;
 };
 
 } // LockAwareTransactions

Modified: sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.h
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.h (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.h 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -21,10 +21,11 @@
 #include <pthread.h>
 
 #include <fstream>
+
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
 //-----------------------------------------------------------------------------
@@ -99,15 +100,15 @@
 
    LinkedList()
    {
-#ifndef BOOST_STM_T_USE_BOOST_MUTEX
- pthread_mutex_init (&list_lock_, 0);
-#endif
+//#ifndef BOOST_STM_T_USE_BOOST_MUTEX
+// pthread_mutex_init (&list_lock_, 0);
+//#endif
       head_.value() = T();
    }
 
    ~LinkedList() { quick_clear(); }
 
- pthread_mutex_t* get_list_lock() { return &list_lock_; }
+ mutex_type* get_list_lock() { return &list_lock_; }
 
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
@@ -519,7 +520,7 @@
    }
 
    list_node<T> head_;
- pthread_mutex_t list_lock_;
+ mutex_type list_lock_;
 };
 
 } // LockAwareTransactions

Modified: sandbox/stm/branches/vbe/libs/stm/test/txLinearLock.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/txLinearLock.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/txLinearLock.cpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -19,16 +19,16 @@
 
 static boost::stm::native_trans<int> gInt1;
 static boost::stm::native_trans<int> gInt2;
+
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
-static pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
-static boost::mutex lock1;
-static boost::mutex lock2;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
+static mutex_type lock1;
+static mutex_type lock2;
+
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
 using namespace boost;

Modified: sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -22,19 +22,16 @@
 static newSyntaxNS::LinkedList< list_node_type > *llist = 0;
 
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
-static pthread_mutex_t L = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t L2 = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t L3 = PTHREAD_MUTEX_INITIALIZER;
-//static pthread_mutex_t L4 = PTHREAD_MUTEX_INITIALIZER;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
-static boost::mutex L;
-static boost::mutex L2;
-static boost::mutex L3;
-//static boost::mutex L4;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
+static mutex_type L;
+static mutex_type L2;
+static mutex_type L3;
+//static mutex_type L4;
+
 using namespace boost::stm;
 using namespace boost;
 

Modified: sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.h
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.h (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.h 2009-11-08 18:38:32 EST (Sun, 08 Nov 2009)
@@ -23,12 +23,14 @@
 #include <pthread.h>
 
 #include <fstream>
+
 #ifndef BOOST_STM_T_USE_BOOST_MUTEX
-typedef pthread_mutex_t mutex_type;
+typedef boost::stm::exclusive_lock_adapter<pthread_mutex_t> mutex_type;
 #else
-typedef boost::mutex mutex_type;
+typedef boost::stm::exclusive_lock_adapter<boost::mutex> mutex_type;
 #endif
 
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 namespace newSyntaxNS
@@ -101,15 +103,15 @@
 
    LinkedList()
    {
-#ifndef BOOST_STM_T_USE_BOOST_MUTEX
- pthread_mutex_init (&list_lock_, 0);
-#endif
+//#ifndef BOOST_STM_T_USE_BOOST_MUTEX
+// pthread_mutex_init (&list_lock_, 0);
+//#endif
       head_.value() = T();
    }
 
    ~LinkedList() { quick_clear(); }
 
- pthread_mutex_t* get_list_lock() { return &list_lock_; }
+ mutex_type* get_list_lock() { return &list_lock_; }
 
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
@@ -520,7 +522,7 @@
    }
 
    list_node<T> head_;
- pthread_mutex_t list_lock_;
+ mutex_type list_lock_;
 };
 
 } // LockAwareTransactions


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