Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57224 - 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-10-29 10:18:00


Author: viboes
Date: 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
New Revision: 57224
URL: http://svn.boost.org/trac/boost/changeset/57224

Log:
TBoost.STM vbe: LATM generic mutex ongoing
* changing return type to bool for trylock
* Added stm/synch/mutex.hpp adapter to latm mutexes
* Added synchro/poly/lock.hpp
* Added stm::lock/unlock/try_lock
Added:
   sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp (contents, props changed)
   sandbox/stm/branches/vbe/boost/synchro/poly/
   sandbox/stm/branches/vbe/boost/synchro/poly/lock.hpp (contents, props changed)
Text files modified:
   sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 8 ++++++
   sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp | 13 +++++----
   sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp | 13 +++++----
   sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp | 9 +++---
   sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp | 13 +++++----
   sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp | 11 ++++---
   sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp | 9 +++---
   sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp | 6 ++--
   sandbox/stm/branches/vbe/boost/stm/latm/datatypes.hpp | 7 +++-
   sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp | 8 +++---
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 51 ++++++++++-----------------------------
   sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 | 12 +++++++--
   12 files changed, 79 insertions(+), 81 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-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -132,6 +132,14 @@
 #define BOOST_STM_LATM_STATIC_MODE 1
 #endif
 
+
+///////////////////////////////////////////////////////////////////////////////
+// Define BOOST_STM_LATM_GENERIC when you want Boost.STM to manage with arbitrary mutex
+
+//#define BOOST_STM_LATM_GENERIC 1
+
+
+///////////////////////////////////////////////////////////////////////////////
 #endif // BOOST_STM_DETAIL_CONFIG_H
 
 

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -172,7 +172,7 @@
 //----------------------------------------------------------------------------
 // only allow one thread to execute any of these methods at a time
 //----------------------------------------------------------------------------
-inline int transaction::def_full_pthread_trylock_mutex(latm::mutex_type* mutex)
+inline bool transaction::def_full_pthread_trylock_mutex(latm::mutex_type* mutex)
 {
    if (transaction* t = get_inflight_tx_of_same_thread(false))
    {
@@ -189,13 +189,13 @@
       //synchro::unlock(*latm_lock());
        }
 
- if (hadLock) return 0;
- else return synchro::try_lock(*mutex)?0:1;
+ if (hadLock) return true;
+ else return synchro::try_lock(*mutex);
    }
 
    //int val = synchro::trylock(*mutex);
    //if (0 != val) return val;
- if (!synchro::try_lock(*mutex)) return 1;
+ if (!synchro::try_lock(*mutex)) return false;
 
    //synchro::lock(latmMutex_);
     synchro::lock_guard<Mutex> lock_l(latm::instance().latmMutex_);
@@ -209,7 +209,8 @@
       {
          synchro::unlock(*mutex);
          //synchro::unlock(latmMutex_);
- return -1;
+ //return -1;
+ return false;
       }
    }
    catch (...)
@@ -223,7 +224,7 @@
    //synchro::unlock(latmMutex_);
    // note: we do not release the transactionsInFlightMutex - this will prevents
    // new transactions from starting until this lock is released
- return 0;
+ return true;
 }
 
 //----------------------------------------------------------------------------

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -170,7 +170,7 @@
 //----------------------------------------------------------------------------
 // only allow one thread to execute any of these methods at a time
 //----------------------------------------------------------------------------
-inline int transaction::def_tm_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex)
+inline bool transaction::def_tm_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex)
 {
    if (transaction* t = get_inflight_tx_of_same_thread(false))
    {
@@ -188,8 +188,8 @@
       //synchro::unlock(*latm_lock());
       }
 
- if (hadLock) return 0;
- else return synchro::try_lock(*mutex)?0:1;
+ if (hadLock) return true;
+ else return synchro::try_lock(*mutex);
    }
 
    //synchro::unique_lock<Mutex> lock_m(*mutex, synchro::try_to_lock);
@@ -197,7 +197,7 @@
    
    //int val = synchro::try_lock(*mutex);
    //if (0 != val) return val;
- if (!synchro::try_lock(*mutex)) return 1;
+ if (!synchro::try_lock(*mutex)) return false;
 
    //synchro::lock(latmMutex_);
    synchro::lock_guard<Mutex> lock_l(latm::instance().latmMutex_);
@@ -211,7 +211,8 @@
       {
          synchro::unlock(*mutex); // BUG ???
          //synchro::unlock(latmMutex_);
- return -1;
+ //return -1;
+ return false;
       }
    }
    catch (...)
@@ -225,7 +226,7 @@
    //synchro::unlock(latmMutex_);
    // note: we do not release the transactionsInFlightMutex - this will prevents
    // new transactions from starting until this lock is released
- return 0;
+ return true;
 }
 
 //----------------------------------------------------------------------------

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -211,7 +211,7 @@
 //----------------------------------------------------------------------------
 // only allow one thread to execute any of these methods at a time
 //----------------------------------------------------------------------------
-inline int transaction::def_tx_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex)
+inline bool transaction::def_tx_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex)
 {
    //--------------------------------------------------------------------------
 
@@ -221,7 +221,7 @@
 
    //int val = synchro::try_lock(*mutex);
    //if (0 != val) return val;
- if (!synchro::try_lock(*mutex)) return 1;
+ if (!synchro::try_lock(*mutex)) return false;
 
    synchro::lock(latm::instance().latmMutex_);
 
@@ -243,7 +243,8 @@
       {
          synchro::unlock(*mutex);
          synchro::unlock(latm::instance().latmMutex_);
- return -1;
+ //return -1;
+ return false;
       }
    }
    catch (...)
@@ -258,7 +259,7 @@
 
    // note: we do not release the transactionsInFlightMutex - this will prevents
    // new transactions from starting until this lock is released
- return 0;
+ return true;
 }
 
 //----------------------------------------------------------------------------

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -187,7 +187,7 @@
 //----------------------------------------------------------------------------
 // only allow one thread to execute any of these methods at a time
 //----------------------------------------------------------------------------
-inline int transaction::dir_full_pthread_trylock_mutex(latm::mutex_type* mutex)
+inline bool transaction::dir_full_pthread_trylock_mutex(latm::mutex_type* mutex)
 {
    if (transaction* t = get_inflight_tx_of_same_thread(false))
    {
@@ -202,15 +202,15 @@
       latm::instance().latmLockedLocksOfThreadMap_[mutex] = this_thread::get_id();
       synchro::unlock(*latm_lock());
 
- if (hadLock) return 0;
- else return synchro::try_lock(*mutex)?0:1;
+ if (hadLock) return true;
+ else return synchro::try_lock(*mutex);
    }
 
    //synchro::unique_lock<Mutex> lock_m(*mutex, synchro::try_to_lock);
    //if (lock_m) return true;
    //int val = synchro::try_lock(*mutex);
    //if (0 != val) return val;
- if (!synchro::try_lock(*mutex)) return 1;
+ if (!synchro::try_lock(*mutex)) return false;
 
    //synchro::lock(latmMutex_);
    synchro::lock_guard<Mutex> lock_l(latm::instance().latmMutex_);
@@ -224,7 +224,8 @@
       {
          //synchro::unlock(*mutex);
          synchro::unlock(latm::instance().latmMutex_);
- return -1;
+ //return -1;
+ return false;
       }
    }
    catch (...)
@@ -238,7 +239,7 @@
    //synchro::unlock(latmMutex_);
    // note: we do not release the transactionsInFlightMutex - this will prevents
    // new transactions from starting until this lock is released
- return 0;
+ return true;
 }
 
 //----------------------------------------------------------------------------

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -175,7 +175,7 @@
 //----------------------------------------------------------------------------
 // only allow one thread to execute any of these methods at a time
 //----------------------------------------------------------------------------
-inline int transaction::dir_tm_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex)
+inline bool transaction::dir_tm_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex)
 {
    if (transaction* t = get_inflight_tx_of_same_thread(false))
    {
@@ -184,12 +184,12 @@
       synchro::lock(*latm_lock());
       latm::instance().latmLockedLocksOfThreadMap_[mutex] = this_thread::get_id();
       synchro::unlock(*latm_lock());
- return synchro::try_lock(*mutex)?0:1;
+ return synchro::try_lock(*mutex);
    }
 
    //int val = synchro::try_lock(*mutex);
    //if (0 != val) return val;
- if (!synchro::try_lock(*mutex)) return 1;
+ if (!synchro::try_lock(*mutex)) return false;
 
    synchro::lock(latm::instance().latmMutex_);
 
@@ -202,7 +202,8 @@
       {
          synchro::unlock(*mutex);
          synchro::unlock(latm::instance().latmMutex_);
- return -1;
+ //return -1;
+ return false;
       }
    }
    catch (...)
@@ -216,7 +217,7 @@
    synchro::unlock(latm::instance().latmMutex_);
    // note: we do not release the transactionsInFlightMutex - this will prevents
    // new transactions from starting until this lock is released
- return 0;
+ return true;
 }
 
 //----------------------------------------------------------------------------

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -245,7 +245,7 @@
 //----------------------------------------------------------------------------
 // only allow one thread to execute any of these methods at a time
 //----------------------------------------------------------------------------
-inline int transaction::dir_tx_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex)
+inline bool transaction::dir_tx_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex)
 {
    //--------------------------------------------------------------------------
    throw "might not be possible to implement trylock for this";
@@ -254,7 +254,7 @@
 
    //int val = synchro::try_lock(*mutex);
    //if (0 != val) return val;
- if (!synchro::try_lock(*mutex)) return 1;
+ if (!synchro::try_lock(*mutex)) return false;
 
    synchro::lock(latm::instance().latmMutex_);
 
@@ -275,7 +275,8 @@
       {
          synchro::unlock(*mutex);
          synchro::unlock(latm::instance().latmMutex_);
- return -1;
+ //return -1;
+ return false;
       }
    }
    catch (...)
@@ -290,7 +291,7 @@
 
    // note: we do not release the transactionsInFlightMutex - this will prevents
    // new transactions from starting until this lock is released
- return 0;
+ return true;
 }
 
 //----------------------------------------------------------------------------

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-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -330,8 +330,8 @@
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
-#if 0
-inline int boost::stm::transaction::pthread_trylock(latm::mutex_type* mutex)
+
+inline bool boost::stm::transaction::pthread_trylock(latm::mutex_type* mutex)
 {
    //using namespace boost::stm;
 
@@ -350,7 +350,7 @@
       throw "invalid LATM type";
    }
 }
-#endif
+
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 inline void boost::stm::transaction::pthread_unlock(latm::mutex_type* 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-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -18,13 +18,16 @@
 #include <boost/stm/datatypes.hpp>
 #include <set>
 #include <map>
+#if BOOST_STM_LATM_GENERIC
+#include <boost/stm/synchro/poly/lock.hpp>
+#endif
 
 namespace boost { namespace stm { namespace latm {
     struct static_mode {};
 #if BOOST_STM_LATM_GENERIC
- //typedef synchro::poly::mutex mutex_type;
+ typedef boost::synchro::poly::exclusive_lock mutex_type;
 #else
- typedef Mutex mutex_type;
+ typedef Mutex mutex_type;
 #endif
 
     typedef std::set<thread_id_t> thread_id_set;

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-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -35,8 +35,8 @@
 
 //---------------------------------------------------------------------------
 #ifdef PERFORMING_LATM
-#define BOOST_STM_LOCK(a) boost::stm::transaction::lock_(a)
-#define BOOST_STM_UNLOCK(a) boost::stm::transaction::unlock_(a)
+#define BOOST_STM_LOCK(a) boost::stm::lock(a)
+#define BOOST_STM_UNLOCK(a) boost::stm::unlock(a)
 #else
 #define BOOST_STM_LOCK(a) boost::synchro::lock(a)
 #define BOOST_STM_UNLOCK(a) boost::synchro::unlock(a)
@@ -138,7 +138,7 @@
       lock_ = mutex;
       if (thread_has_lock(mutex)) return;
 
- BOOST_STM_LOCK(mutex);
+ BOOST_STM_LOCK(*mutex);
       hasLock_ = true;
 
       insert_into_threaded_lock_map(mutex);
@@ -149,7 +149,7 @@
       if (hasLock_)
       {
          hasLock_ = false;
- BOOST_STM_UNLOCK(lock_);
+ BOOST_STM_UNLOCK(*lock_);
          remove_thread_has_lock(lock_);
       }
    }

Added: sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp
==============================================================================
--- (empty file)
+++ sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -0,0 +1,84 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Justin E. Gottchlich 2009.
+// (C) Copyright Vicente J. Botet Escriba 2009.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/stm for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_STM_SYNCH_MUTEX__HPP
+#define BOOST_STM_SYNCH_MUTEX__HPP
+
+#include <boost/synchro/exceptions.hpp>
+#include <boost/synchro/time.hpp>
+#include <boost/synchro/detail/deleted_functions.hpp>
+#include <boost/synchro/poly/lock.hpp>
+
+namespace boost { namespace stm {
+
+template <typename Lockable>
+class latm_exclusive_lock_adapter : public boost::synchro::poly::exclusive_lock
+{
+public:
+ typedef Lockable lockable_type;
+
+ BOOST_COPY_CONSTRUCTOR_DELETE(latm_exclusive_lock_adapter) /*< disable copy construction >*/
+ BOOST_COPY_ASSIGNEMENT_DELETE(latm_exclusive_lock_adapter) /*< disable copy asignement >*/
+ latm_exclusive_lock_adapter() {}
+ ~latm_exclusive_lock_adapter() {}
+
+ void lock() {stm::lock(lock_);}
+ void unlock() {stm::unlock(lock_);}
+ bool try_lock() { return stm::try_lock(lock_);}
+
+protected:
+ lockable_type* the_lock() { return &lock_; }
+ mutable lockable_type lock_;
+};
+
+template <typename Lockable>
+void lock(latm_exclusive_lock_adapter<Lockable>& lock) {transaction::pthread_lock(&lock);}
+template <typename Lockable>
+bool try_lock(latm_exclusive_lock_adapter<Lockable>& lock) {return transaction::pthread_trylock(&lock);}
+template <typename Lockable>
+void unlock(latm_exclusive_lock_adapter<Lockable>& lock) {transaction::pthread_unlock(&lock);}
+
+#if 0
+template <typename TimedLock>
+class latm_timed_lock_adapter
+ : public latm_exclusive_lock_adapter<TimedLock>
+{
+public:
+ typedef TimedLock lockable_base_type;
+
+ timed_lockable_adapter() {}
+
+ template<typename Clock, typename Duration>
+ bool try_lock_until(chrono::time_point<Clock, Duration> const & abs_time)
+ {return transaction::try_lock_until(the_lock(), abs_time);}
+ template<typename Rep, typename Period>
+ bool try_lock_for(chrono::duration<Rep, Period> const & rel_time)
+ {return transaction::try_lock_for(the_lock(), rel_time);}
+
+
+ template<typename Clock, typename Duration>
+ void lock_until(chrono::time_point<Clock, Duration> const & abs_time)
+ {transaction::lock_until(the_lock(), abs_time);}
+ template<typename Rep, typename Period>
+ void lock_for(chrono::duration<Rep, Period> const & rel_time)
+ {transaction::::lock_for(the_lock(), rel_time);}
+
+protected:
+ //TimedLock& the_lock() {return *static_cast<TimedLock*>(&this->lock_);}
+};
+
+#endif
+
+}
+}
+#endif

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-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -306,46 +306,17 @@
    // Lock Aware Transactional Memory support methods
    //--------------------------------------------------------------------------
 
- #ifdef WIN32
- template <typename T>
- inline static int lock_(T *lock) { throw "unsupported lock type"; }
-
- template <typename T>
- inline static int trylock_(T *lock) { throw "unsupported lock type"; }
-
- template <typename T>
- inline static int unlock_(T *lock) { throw "unsupported lock type"; }
-
- template <>
- inline static int lock_(Mutex &lock) { return pthread_lock(&lock); }
-
- template <>
- inline static int lock_(Mutex *lock) { return pthread_lock(lock); }
-
- template <>
- inline static int trylock_(Mutex &lock) { return pthread_trylock(&lock); }
-
- template <>
- inline static int trylock_(Mutex *lock) { return pthread_trylock(lock); }
-
- template <>
- inline static int unlock_(Mutex &lock) { return pthread_unlock(&lock); }
-
- template <>
- inline static int unlock_(Mutex *lock) { return pthread_unlock(lock); }
- #else
    inline static void lock_(latm::mutex_type &lock) { pthread_lock(&lock); }
    inline static void lock_(latm::mutex_type *lock) { pthread_lock(lock); }
 
- //inline static int trylock_(latm::mutex_type &lock) { return pthread_trylock(&lock); }
- //inline static int trylock_(latm::mutex_type *lock) { return pthread_trylock(lock); }
+ inline static bool trylock_(latm::mutex_type &lock) { return pthread_trylock(&lock); }
+ inline static bool trylock_(latm::mutex_type *lock) { return pthread_trylock(lock); }
 
    inline static void unlock_(latm::mutex_type &lock) { pthread_unlock(&lock); }
    inline static void unlock_(latm::mutex_type *lock) { pthread_unlock(lock); }
- #endif
 
    static void pthread_lock(latm::mutex_type* lock);
- //static int pthread_trylock(latm::mutex_type* lock);
+ static bool pthread_trylock(latm::mutex_type* lock);
    static void pthread_unlock(latm::mutex_type* lock);
 
    //--------------------------------------------------------------------------
@@ -1280,30 +1251,30 @@
    // deferred updating locking methods
    //--------------------------------------------------------------------------
    static void def_full_pthread_lock_mutex(latm::mutex_type* mutex);
- static int def_full_pthread_trylock_mutex(latm::mutex_type* mutex);
+ static bool def_full_pthread_trylock_mutex(latm::mutex_type* mutex);
    static void def_full_pthread_unlock_mutex(latm::mutex_type* mutex);
 
    static void def_tm_conflicting_lock_pthread_lock_mutex(latm::mutex_type* mutex);
- static int def_tm_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex);
+ static bool def_tm_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex);
    static void def_tm_conflicting_lock_pthread_unlock_mutex(latm::mutex_type* mutex);
 
    static void def_tx_conflicting_lock_pthread_lock_mutex(latm::mutex_type* mutex);
- static int def_tx_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex);
+ static bool def_tx_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex);
    static void def_tx_conflicting_lock_pthread_unlock_mutex(latm::mutex_type* mutex);
 
    //--------------------------------------------------------------------------
    // direct updating locking methods
    //--------------------------------------------------------------------------
    static void dir_full_pthread_lock_mutex(latm::mutex_type* mutex);
- static int dir_full_pthread_trylock_mutex(latm::mutex_type* mutex);
+ static bool dir_full_pthread_trylock_mutex(latm::mutex_type* mutex);
    static void dir_full_pthread_unlock_mutex(latm::mutex_type* mutex);
 
    static void dir_tm_conflicting_lock_pthread_lock_mutex(latm::mutex_type* mutex);
- static int dir_tm_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex);
+ static bool dir_tm_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex);
    static void dir_tm_conflicting_lock_pthread_unlock_mutex(latm::mutex_type* mutex);
 
    static void dir_tx_conflicting_lock_pthread_lock_mutex(latm::mutex_type* mutex);
- static int dir_tx_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex);
+ static bool dir_tx_conflicting_lock_pthread_trylock_mutex(latm::mutex_type* mutex);
    static void dir_tx_conflicting_lock_pthread_unlock_mutex(latm::mutex_type* mutex);
 
    //--------------------------------------------------------------------------
@@ -1880,6 +1851,10 @@
 
 inline transaction* current_transaction() {return transaction::current_transaction();}
 
+inline void lock(latm::mutex_type& lock) {transaction::pthread_lock(&lock);}
+inline bool try_lock(latm::mutex_type& lock) {return transaction::pthread_trylock(&lock);}
+inline void unlock(latm::mutex_type& lock) {transaction::pthread_unlock(&lock);}
+
 
 template <class T> T* cache_allocate(transaction* t) {
     #if defined(BOOST_STM_CACHE_USE_MEMORY_MANAGER) && defined (USE_STM_MEMORY_MANAGER)

Added: sandbox/stm/branches/vbe/boost/synchro/poly/lock.hpp
==============================================================================
--- (empty file)
+++ sandbox/stm/branches/vbe/boost/synchro/poly/lock.hpp 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -0,0 +1,75 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-2009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_SYNCHRO_POLY_LOCK__HPP
+#define BOOST_SYNCHRO_POLY_LOCK__HPP
+#if 0
+#include <boost/chrono/chrono.hpp>
+#include <boost/thread/thread_time.hpp>
+#endif
+namespace boost { namespace synchro { namespace poly {
+
+//////////////////////////////////////////////////////////////////////////////
+
+struct exclusive_lock {
+ virtual ~exclusive_lock(){};
+ virtual void lock()=0;
+ virtual void unlock()=0;
+ virtual bool try_lock()=0;
+};
+
+
+//////////////////////////////////////////////////////////////////////////////
+#if 0
+struct timed_lock : exclusive_lock {
+ ~timed_lock(){};
+ virtual bool try_lock_until(chrono::system_clock::time_point const & abs_time)=0;
+ virtual bool try_lock_for(chrono::nanoseconds const & relative_time)=0;
+ virtual void lock_until(chrono::system_clock::time_point const & abs_time)=0;
+ virtual void lock_for(chrono::nanoseconds const & relative_time)=0;
+};
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+struct sharable_lock : timed_lock {
+ virtual ~sharable_lock();
+ virtual void lock_shared()=0;
+ virtual bool try_lock_shared()=0;
+ virtual void unlock_shared()=0;
+ virtual bool try_lock_shared_until(chrono::system_clock::time_point const & abs_time)=0;
+ virtual bool try_lock_shared_for(chrono::nanoseconds const & relative_time)=0;
+ virtual void lock_shared_until(chrono::system_clock::time_point const & abs_time)=0;
+ virtual void lock_shared_for(chrono::nanoseconds const & relative_time)=0;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+struct upgradable_lock : sharable_lock {
+ virtual ~upgradable_lock();
+ virtual void lock_upgrade()=0;
+
+ virtual bool try_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)=0;
+ virtual bool try_lock_shared_for(chrono::nanoseconds const & relative_time)=0;
+ virtual void lock_upgrade_until(chrono::system_clock::time_point const & abs_time)=0;
+ virtual void lock_shared_for(chrono::nanoseconds const & relative_time)=0;
+
+ virtual void unlock_upgrade()=0;
+ virtual void unlock_upgrade_and_lock()=0;
+ virtual void unlock_and_lock_upgrade()=0;
+ virtual void unlock_and_lock_shared()=0;
+ virtual void unlock_upgrade_and_lock_shared()=0;
+};
+#endif
+}
+}
+}
+
+#endif

Modified: sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 2009-10-29 10:17:58 EDT (Thu, 29 Oct 2009)
@@ -53,6 +53,8 @@
 
     alias def_invalid
         :
+ ########### fails sometimes
+ #assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 52
             [ run stm : -bench accounts -def -threads 2 -inserts 100 : : : test_accounts_def_t2_i100 ]
             ########### fails sometimes
             #assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 52
@@ -140,7 +142,7 @@
             [ run stm : -bench irrevocable_int -def -threads 2 -inserts 100 : : : test_irrevocable_int_def_t2_i100 ]
             ########### fails sometimes
             #assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 52
- [ run stm : -bench irrevocable_int -def -threads 4 -inserts 100 : : : test_irrevocable_int_def_t4_i100 ]
+ #[ run stm : -bench irrevocable_int -def -threads 4 -inserts 100 : : : test_irrevocable_int_def_t4_i100 ]
 
             ########### deadlock. killed after 0:26. 00% CPU all-modes
             #[ run stm : -bench lot_example -def -threads 2 -inserts 100 -latm full : : : test_lot_example_def_full_t2_i100 ]
@@ -164,7 +166,9 @@
             ##[ run stm : -bench nested_tx -def -threads 2 -inserts 100 -latm tm : : : test_nested_tx_def_tm_t2_i100 ]
             ##[ run stm : -bench nested_tx -def -threads 2 -inserts 100 -latm tx : : : test_nested_tx_def_tx_t2_i100 ]
 
- [ run stm : -bench rbtree -def -threads 4 -inserts 100 : : : test_rbtree_def_t4_i100 ]
+ [ run stm : -bench rbtree -def -threads 2 -inserts 100 : : : test_rbtree_def_t2_i100 ]
+ ########### fails sometimes
+ #[ run stm : -bench rbtree -def -threads 4 -inserts 100 : : : test_rbtree_def_t4_i100 ]
 
             [ run stm : -bench smart -def -threads 4 -inserts 100 : : : test_smart_def_t4_i100 ]
 
@@ -220,7 +224,7 @@
             ########### fails
             #[ run stm : -bench ll -dir -threads 2 -inserts 100 -latm tx : : : test_ll_dir_t2_tx_i100 ]
             ########### fails sometimes
- [ run stm : -bench ll -dir -threads 4 -inserts 100 -latm tx : : : test_ll_dir_t4_tx_i100 ]
+ #[ run stm : -bench ll -dir -threads 4 -inserts 100 -latm tx : : : test_ll_dir_t4_tx_i100 ]
 
             ########### fails with CHECK all-modes
             #/bin/sh: line 4: 3764 Aborted (core dumped) "bin/test_tx_linear_lock_dir_t2.test/gcc-3.4.4/debug/threading-multi/test_tx_linear_lock_dir_t2.exe" > "bin/test_tx_linear_lock_dir_t2.test/gcc-3.4.4/debug/threading-multi/test_tx_linear_lock_dir_t2.output" 2>&1
@@ -315,6 +319,8 @@
             [ run ../example/numeric.cpp ]
             [ run ../example/tx/pointer.cpp ]
             [ run ../example/counter_ptr.cpp ]
+ # fails sometimes
+ # assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 52
             [ run ../example/non_tx_counter.cpp ]
     ;
 


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