Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57487 - in sandbox/stm/branches/vbe: boost/stm boost/stm/synch libs/stm/test
From: vicente.botet_at_[hidden]
Date: 2009-11-08 10:41:24


Author: viboes
Date: 2009-11-08 10:41:22 EST (Sun, 08 Nov 2009)
New Revision: 57487
URL: http://svn.boost.org/trac/boost/changeset/57487

Log:
TBoost.STM vbe:
* Added stm::lock_guard, stm::unique_lock
* Use of stm::lock_guard, stm::unique_lock on test programs
* Added synchronized language-like macros

Added:
   sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp (contents, props changed)
   sandbox/stm/branches/vbe/boost/stm/synch/synchronized.hpp (contents, props changed)
   sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp (contents, props changed)
Text files modified:
   sandbox/stm/branches/vbe/boost/stm/synch.hpp | 3 ++
   sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp | 38 +++++++++++++++++++++++-----
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 9 ------
   sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 | 52 ++++++++++++++++++++++-----------------
   sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp | 17 ++++++++----
   sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp | 12 ++++++---
   sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp | 7 +++-
   sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp | 14 ++++------
   sandbox/stm/branches/vbe/libs/stm/test/lotExample.cpp | 20 +++++++-------
   sandbox/stm/branches/vbe/libs/stm/test/nestedTxs.cpp | 21 ++++++----------
   sandbox/stm/branches/vbe/libs/stm/test/testLL_latm.h | 11 +++----
   sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.h | 11 +++----
   sandbox/stm/branches/vbe/libs/stm/test/txLinearLock.cpp | 18 +++++++------
   sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp | 21 ++++++----------
   sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.h | 6 ++--
   15 files changed, 142 insertions(+), 118 deletions(-)

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -16,6 +16,9 @@
 
 #include <boost/stm/synch/auto_lock.hpp>
 #include <boost/stm/synch/mutex.hpp>
+#include <boost/stm/synch/lock_guard.hpp>
+#include <boost/stm/synch/unique_lock.hpp>
+#include <boost/stm/synch/synchronized.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 #endif // TRANSACTION_H

Added: sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp
==============================================================================
--- (empty file)
+++ sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp 2009-11-08 10:41:22 EST (Sun, 08 Nov 2009)
@@ -0,0 +1,117 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_LOCK_GUARD__HPP
+#define BOOST_STM_SYNCH_LOCK_GUARD__HPP
+
+//-----------------------------------------------------------------------------
+#include <boost/synchro/tags.hpp>
+#include <boost/synchro/exceptions.hpp>
+#include <boost/synchro/lockable/lock.hpp>
+#include <boost/synchro/lockable/unlock.hpp>
+//-----------------------------------------------------------------------------
+
+namespace boost {
+namespace stm {
+
+#if 0
+ template<typename Mutex, Mutex& m>
+ class static_lock_guard {
+ private:
+
+ explicit static_lock_guard(static_lock_guard&);
+ static_lock_guard& operator=(static_lock_guard&);
+ public:
+ static_lock_guard()
+ {
+ lock(m);
+ }
+ explicit static_lock_guard(adopt_lock_t)
+ {}
+ ~static_lock_guard() {
+ unlock(m);
+ }
+ };
+#endif
+ template<typename Mutex>
+ class lock_guard {
+ private:
+ //Mutex& m;
+ stm::exclusive_ref_lock_adapter<Mutex> m;
+
+ explicit lock_guard(lock_guard&);
+ lock_guard& operator=(lock_guard&);
+ public:
+ explicit lock_guard(Mutex& m_)
+ : m(m_)
+ {
+ m.lock();
+ }
+ lock_guard(Mutex& m_, bool cnd, adopt_lock_t)
+ : m(m_)
+ {}
+ ~lock_guard() {
+ m.unlock();
+ }
+ };
+
+#if 0
+ template<typename Mutex, Mutex& m>
+ class static_lock_guard_if {
+ private:
+ bool cnd_;
+
+ explicit static_lock_guard_if(static_lock_guard_if&);
+ static_lock_guard_if& operator=(static_lock_guard_if&);
+ public:
+ explicit static_lock_guard_if(bool cnd)
+ : cnd_(cnd)
+ {
+ if (cnd_) lock(m);
+ }
+ static_lock_guard_if(bool cnd,adopt_lock_t)
+ : cnd_(cnd)
+ {}
+ ~static_lock_guard_if() {
+ if (cnd_) unlock(m);
+ }
+ };
+
+ template<typename Mutex>
+ class lock_guard_if {
+ private:
+ Mutex& m;
+ bool cnd_;
+
+ explicit lock_guard_if(lock_guard_if&);
+ lock_guard_if& operator=(lock_guard_if&);
+ public:
+ lock_guard_if(Mutex& m_, bool cnd)
+ : m(m_)
+ , cnd_(cnd)
+ {
+ if (cnd_) lock(m);
+ }
+ lock_guard_if(Mutex& m_, bool cnd, adopt_lock_t)
+ : m(m_)
+ , cnd_(cnd)
+ {}
+ ~lock_guard_if() {
+ if (cnd_) unlock(m);
+ }
+ };
+#endif
+
+}}
+#endif // BOOST_STM_SYNCH_LOCK_GUARD__HPP
+

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -14,10 +14,13 @@
 #ifndef BOOST_STM_SYNCH_MUTEX__HPP
 #define BOOST_STM_SYNCH_MUTEX__HPP
 
+#include <boost/stm/detail/config.hpp>
+//-----------------------------------------------------------------------------
 #include <boost/synchro/exceptions.hpp>
 #include <boost/synchro/time.hpp>
 #include <boost/synchro/detail/deleted_functions.hpp>
 #include <boost/synchro/poly/lock.hpp>
+#include <boost/synchro/poly/ref_lock_adapter.hpp>
 
 namespace boost { namespace stm {
 
@@ -40,25 +43,46 @@
     lockable_type* the_lock() { return &lock_; }
     mutable lockable_type lock_;
 };
+#if BOOST_STM_LATM_GENERIC
 
-template <typename Lockable>
+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): lock_(lock) {}
+ exclusive_ref_lock_adapter(lockable_type& lock): st_lock_(lock), dyn_lock_(lock) {}
     ~exclusive_ref_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_);}
 
 protected:
- lockable_type* the_lock() { return &lock_; }
- mutable lockable_type& lock_;
+ lockable_type* the_lock() { return &st_lock_; }
+ mutable lockable_type& st_lock_;
+ //mutable Poly<lockable_type, Base> dyn_lock_;
+};
+#else
+template <typename Lockable >
+class exclusive_ref_lock_adapter
+{
+public:
+ typedef Lockable lockable_type;
+
+ exclusive_ref_lock_adapter(lockable_type& lock): st_lock_(lock) {}
+ ~exclusive_ref_lock_adapter() {}
+
+ void lock() {stm::lock(st_lock_);}
+ void unlock() {stm::unlock(st_lock_);}
+ bool try_lock() { return stm::try_lock(st_lock_);}
+
+protected:
+ lockable_type* the_lock() { return &st_lock_; }
+ mutable lockable_type& st_lock_;
 };
 
+#endif
 template <typename Lockable>
 void lock(exclusive_lock_adapter<Lockable>& lock) {transaction::pthread_lock(&lock);}
 template <typename Lockable>

Added: sandbox/stm/branches/vbe/boost/stm/synch/synchronized.hpp
==============================================================================
--- (empty file)
+++ sandbox/stm/branches/vbe/boost/stm/synch/synchronized.hpp 2009-11-08 10:41:22 EST (Sun, 08 Nov 2009)
@@ -0,0 +1,61 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_STM_SYNCH_SYNCHRONIZED__HPP
+#define BOOST_STM_SYNCH_SYNCHRONIZED__HPP
+
+#include <boost/stm/synch/unique_lock.hpp>
+
+#define BOOST_STM_SYNCHRONIZE_EXT(VAR_DECL) \
+ if (bool __stop = false) {} else \
+ for (VAR_DECL;!__stop; __stop= true)
+
+#define BOOST_STM_SYNCHRONIZE_TYPE(TYPE, VAR, LOCKABLE) \
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm::unique_lock<TYPE> VAR(LOCKABLE))
+
+#define BOOST_STM_ADOPT_SYNCHRONIZE_TYPE(TYPE, VAR, LOCKABLE) \
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(LOCKABLE, boost::synchro::adopt_lock))
+#define BOOST_STM_DEFER_SYNCHRONIZE_TYPE(TYPE, VAR, LOCKABLE) \
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(LOCKABLE, boost::synchro::defer_lock))
+#define BOOST_STM_TRY_TO_SYNCHRONIZE_TYPE(TYPE, VAR, LOCKABLE) \
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(LOCKABLE, boost::synchro::try_to_lock))
+#define BOOST_STM_TRY_TO_SYNCHRONIZE_TYPE_UNTIL(TYPE, VAR, LOCKABLE, ABS_TIME) \
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(LOCKABLE, ABS_TIME))
+#define BOOST_STM_SYNCHRONIZE_TYPE_UNTIL(TYPE, VAR, LOCKABLE, ABS_TIME) \
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(ABS_TIME, LOCKABLE))
+
+#define BOOST_STM_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
+ BOOST_STM_SYNCHRONIZE_TYPE(boost::mutex, VAR, LOCKABLE)
+#define BOOST_STM_ADOPT_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
+ BOOST_STM_ADOPT_SYNCHRONIZE_TYPE(boost::mutex, VAR, LOCKABLE)
+#define BOOST_STM_DEFER_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
+ BOOST_STM_DEFER_SYNCHRONIZE_TYPE(boost::mutex, VAR, LOCKABLE)
+#define BOOST_STM_TRY_TO_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
+ BOOST_STM_TRY_TO_SYNCHRONIZE_TYPE(boost::mutex, VAR, LOCKABLE)
+#define BOOST_STM_SYNCHRONIZE_VAR_UNTIL(VAR, LOCKABLE, ABS_TIME) \
+ BOOST_STM_SYNCHRONIZE_TYPE_UNTIL(boost::mutex, VAR, LOCKABLE, ABS_TIME)
+#define BOOST_STM_TRY_TO_SYNCHRONIZE_VAR_UNTIL(VAR, LOCKABLE, ABS_TIME) \
+ BOOST_STM_TRY_TO_SYNCHRONIZE_TYPE_UNTIL(boost::mutex, VAR, LOCKABLE, ABS_TIME)
+
+#define BOOST_STM_SYNCHRONIZE(LOCKABLE) \
+ BOOST_STM_SYNCHRONIZE_VAR(_, LOCKABLE)
+#define BOOST_STM_ADOPT_SYNCHRONIZE(LOCKABLE) \
+ BOOST_STM_ADOPT_SYNCHRONIZE_VAR(_, LOCKABLE)
+#define BOOST_STM_DEFER_SYNCHRONIZE(LOCKABLE) \
+ BOOST_STM_DEFER_SYNCHRONIZE_VAR(_, LOCKABLE)
+#define BOOST_STM_TRY_TO_SYNCHRONIZE(LOCKABLE) \
+ BOOST_STM_TRY_TO_SYNCHRONIZE_VAR(_, LOCKABLE)
+#define BOOST_STM_SYNCHRONIZE_UNTIL(LOCKABLE, ABS_TIME) \
+ BOOST_STM_SYNCHRONIZE_VAR_UNTIL(_, LOCKABLE, ABS_TIME)
+#define BOOST_STM_TRY_TO_SYNCHRONIZE_UNTIL(LOCKABLE, ABS_TIME) \
+ BOOST_STM_TRY_TO_SYNCHRONIZE_VAR_UNTIL(_, LOCKABLE, ABS_TIME)
+
+
+#endif // BOOST_STM_SYNCH_SYNCHRONIZED__HPP

Added: sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp
==============================================================================
--- (empty file)
+++ sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp 2009-11-08 10:41:22 EST (Sun, 08 Nov 2009)
@@ -0,0 +1,237 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (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_UNIQUE_LOCK__HPP
+#define BOOST_STM_SYNCH_UNIQUE_LOCK__HPP
+
+//-----------------------------------------------------------------------------
+#include <boost/synchro/detail/config.hpp>
+//-----------------------------------------------------------------------------
+#include <boost/synchro/tags.hpp>
+#include <boost/synchro/exceptions.hpp>
+#include <boost/stm/synch/mutex.hpp>
+//-----------------------------------------------------------------------------
+
+namespace boost {
+namespace stm {
+
+ template<typename Mutex>
+ class unique_lock
+ {
+ private:
+ stm::exclusive_ref_lock_adapter<Mutex> mtx_;
+ stm::exclusive_ref_lock_adapter<Mutex>* m;
+ bool is_locked;
+
+ unique_lock(unique_lock&);
+ unique_lock& operator=(unique_lock&);
+ public:
+ #if 0
+ unique_lock():
+ m(0),is_locked(false)
+ {}
+ #endif
+
+ explicit unique_lock(Mutex& m_):
+ mtx_(m_),m(&mtx_),is_locked(false)
+ {
+ lock();
+ }
+
+ unique_lock(Mutex& m_,adopt_lock_t):
+ mtx_(m_),m(&mtx_),is_locked(true)
+ {}
+ unique_lock(Mutex& m_,defer_lock_t):
+ mtx_(m_),m(&mtx_),is_locked(false)
+ {}
+ unique_lock(Mutex& 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):
+ mtx_(m_),m(&mtx_),is_locked(false)
+ {
+ lock_for(target_time);
+ }
+ unique_lock(Mutex& m_,system_time const& target_time):
+ mtx_(m_),m(&mtx_),is_locked(false)
+ {
+ lock_until(target_time);
+ }
+#ifdef BOOST_HAS_RVALUE_REFS
+ unique_lock(unique_lock&& other):
+ mtx_(other.mtx_),m(&mtx_),is_locked(other.is_locked)
+ {
+ other.is_locked=false;
+ other.m=0;
+ }
+ unique_lock<Mutex>&& move()
+ {
+ return static_cast<unique_lock<Mutex>&&>(*this);
+ }
+
+
+ unique_lock& operator=(unique_lock<Mutex>&& other)
+ {
+ unique_lock temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ void swap(unique_lock&& other)
+ {
+ std::swap(m,other.m);
+ std::swap(is_locked,other.is_locked);
+ }
+#else
+#if 0
+ unique_lock(detail::thread_move_t<unique_lock<Mutex> > other):
+ mtx_(other.mtx_),m(&mtx_),is_locked(other->is_locked)
+ {
+ other->is_locked=false;
+ other->m=0;
+ }
+
+ operator detail::thread_move_t<unique_lock<Mutex> >()
+ {
+ return move();
+ }
+
+ detail::thread_move_t<unique_lock<Mutex> > move()
+ {
+ return detail::thread_move_t<unique_lock<Mutex> >(*this);
+ }
+
+ unique_lock& operator=(detail::thread_move_t<unique_lock<Mutex> > other)
+ {
+ unique_lock temp(other);
+ swap(temp);
+ return *this;
+ }
+
+ void swap(detail::thread_move_t<unique_lock<Mutex> > other)
+ {
+ std::swap(m,other->m);
+ std::swap(is_locked,other->is_locked);
+ }
+#endif
+ void swap(unique_lock& other)
+ {
+ std::swap(m,other.m);
+ std::swap(is_locked,other.is_locked);
+ }
+
+#endif
+ ~unique_lock()
+ {
+ if(owns_lock())
+ {
+ m->unlock();
+ }
+ }
+ void lock()
+ {
+ if(owns_lock())
+ {
+ throw lock_error();
+ }
+ m->lock();
+ is_locked=true;
+ }
+ bool try_lock()
+ {
+ if(owns_lock())
+ {
+ throw lock_error();
+ }
+ is_locked=m->try_lock();
+ return is_locked;
+ }
+ template<typename TimeDuration>
+ bool lock_for(TimeDuration const& relative_time)
+ {
+ is_locked=m->lock_for(relative_time);
+ return is_locked;
+ }
+
+ bool lock_until(system_time const& absolute_time)
+ {
+ is_locked=m->lock_until(absolute_time);
+ return is_locked;
+ }
+ void unlock()
+ {
+ if(!owns_lock())
+ {
+ throw lock_error();
+ }
+ m->unlock();
+ is_locked=false;
+ }
+
+ typedef void (unique_lock::*bool_type)();
+ operator bool_type() const
+ {
+ return is_locked?&unique_lock::lock:0;
+ }
+ bool operator!() const
+ {
+ return !owns_lock();
+ }
+ bool owns_lock() const
+ {
+ return is_locked;
+ }
+
+ Mutex* mutex() const
+ {
+ return m;
+ }
+
+ Mutex* release()
+ {
+ Mutex* const res=m;
+ m=0;
+ is_locked=false;
+ return res;
+ }
+ };
+
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex>
+ void swap(unique_lock<Mutex>&& lhs,unique_lock<Mutex>&& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#else
+ template<typename Mutex>
+ void swap(unique_lock<Mutex>& lhs,unique_lock<Mutex>& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#endif
+
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex>
+ inline unique_lock<Mutex>&& move(unique_lock<Mutex>&& ul)
+ {
+ return ul;
+ }
+#endif
+
+}}
+#endif // BOOST_STM_SYNCH_UNIQUE_LOCK__HPP
+
+

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -311,15 +311,6 @@
    // Lock Aware Transactional Memory support methods
    //--------------------------------------------------------------------------
 
- inline static void lock_(latm::mutex_type &lock) { pthread_lock(&lock); }
- inline static void lock_(latm::mutex_type *lock) { pthread_lock(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); }
-
    static void pthread_lock(latm::mutex_type* lock);
    static bool pthread_trylock(latm::mutex_type* lock);
    static void pthread_unlock(latm::mutex_type* lock);

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-11-08 10:41:22 EST (Sun, 08 Nov 2009)
@@ -64,11 +64,7 @@
             [ run stm : -bench isolated_int -def -threads 4 -inserts 100 : : : isolated_int_def_t2_i100 ]
 
             [ run stm : -bench linkedlist -def -threads 2 -inserts 100 : : : linkedlist_def_t2_i100 ]
- ########### fails sometimes
- #assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 52
- [ run stm : -bench linkedlist -def -threads 4 -inserts 100 : : : linkedlist_def_t4_i100 ]
 
- [ run stm : -bench ll -def -threads 2 -inserts 100 -latm tm : : : ll_def_tm_t2_i100 ]
             [ run stm : -bench ll -def -threads 4 -inserts 100 -latm tm : : : ll_def_tm_t4_i100 ]
 
 
@@ -91,20 +87,16 @@
             ########### deadlock.
             #[ run stm : -bench lot_example -def -threads 2 -inserts 100 -latm tx : : : lot_example_def_tx_t2_i100 ]
 
- ########### fails with CHECK all-modes
- # /bin/sh: line 4: 4072 Aborted (core dumped) "bin/lit_def_t2.test/gcc-3.4.4/debug/threading-multi/lit_def_t2.exe" > "bin/lit_def_t2.test/gcc-3.4.4/debug/threading-multi/lit_def_t2.output" 2>&1
- ########### deadlock sometimes without CHECK. killed after 0:40. 00% CPU
- #[ run stm : -bench lit_example -def -threads 2 -inserts 100 -latm full : : : lit_example_def_full_t2_i100 ]
- ########### fails
- #[ run stm : -bench lit_example -def -threads 2 -inserts 100 -latm tm : : : lit_example_def_tm_t2_i100 ]
             ########### deadlock
             #[ run stm : -bench lit_example -def -threads 2 -inserts 100 -latm tx : : : lit_example_def_tx_t2_i100 ]
             
 
             ########### livelock. killed after 3:50. 50% CPU
             #[ run stm : -bench nested_tx -def -threads 2 -inserts 100 -latm full : : : nested_tx_def_full_t2_i100 ]
- ##[ run stm : -bench nested_tx -def -threads 2 -inserts 100 -latm tm : : : nested_tx_def_tm_t2_i100 ]
- ##[ run stm : -bench nested_tx -def -threads 2 -inserts 100 -latm tx : : : nested_tx_def_tx_t2_i100 ]
+ ########### livelock
+ #[ run stm : -bench nested_tx -def -threads 2 -inserts 100 -latm tm : : : nested_tx_def_tm_t2_i100 ]
+ ########### livelock
+ #[ run stm : -bench nested_tx -def -threads 2 -inserts 100 -latm tx : : : nested_tx_def_tx_t2_i100 ]
 
             [ run stm : -bench rbtree -def -threads 2 -inserts 100 : : : rbtree_def_t2_i100 ]
 
@@ -144,7 +136,7 @@
             #assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
             ########### deadlock. without CHECK
             [ run stm : -bench tx_linear_lock -dir -threads 2 -inserts 100 -latm full : : : tx_linear_lock_dir_full_t2_i100 ]
- ###########
+ ########### deadlock
             #[ run stm : -bench tx_linear_lock -dir -threads 4 -inserts 100 -latm full : : : tx_linear_lock_dir_full_t4_i100 ]
             ########### deadlock
             #[ run stm : -bench tx_linear_lock -dir -threads 2 -inserts 100 -latm tx : : : tx_linear_lock_dir_tx_t2_i100 ]
@@ -158,10 +150,6 @@
 
             ########### deadlock. killed after 0:20. 00% CPU all-modes all-modes
             #[ run stm : -bench isolated_composed_int_lock -dir -threads 2 -inserts 100 -latm full : : : isolated_composed_int_lock_dir_full_t2_i100 ]
- ########### fails
- #[ run stm : -bench isolated_composed_int_lock -dir -threads 2 -inserts 100 -latm tm : : : isolated_composed_int_lock_dir_tm_t2_i100 ]
- ########### fails
- #[ run stm : -bench isolated_composed_int_lock -dir -threads 2 -inserts 100 -latm tx : : : isolated_composed_int_lock_dir_tx_t2_i100 ]
 
             [ run stm : -bench isolated_composed_int_lock2 -dir -threads 2 -inserts 100 -latm tx : : : isolated_composed_int_lock2_dir_tx_t2_i100 ]
 
@@ -176,15 +164,13 @@
 
             ########### deadlock. killed after 0:40. 00% CPU all-modes
             #[ run stm : -bench lit_example -dir -threads 2 -inserts 100 -latm full : : : lit_example_dir_full_t2_i100 ]
- ########### fails
- #[ run stm : -bench lit_example -dir -threads 2 -inserts 100 -latm tm : : : lit_example_dir_tm_t2_i100 ]
             ########### deadlock
             #[ run stm : -bench lit_example -dir -threads 2 -inserts 100 -latm tx : : : lit_example_dir_tx_t2_i100 ]
 
             ########### livelock. killed after 3:00. 50% CPU
             #[ run stm : -bench nested_tx -dir -threads 2 -inserts 100 -latm full : : : nested_tx_dir_full_t2_i100 ]
- ##[ run stm : -bench nested_tx -dir -threads 2 -inserts 100 -latm tm : : : nested_tx_dir_tm_t2_i100 ]
- ##[ run stm : -bench nested_tx -dir -threads 2 -inserts 100 -latm tx : : : nested_tx_dir_tx_t2_i100 ]
+ #[ run stm : -bench nested_tx -dir -threads 2 -inserts 100 -latm tm : : : nested_tx_dir_tm_t2_i100 ]
+ #[ run stm : -bench nested_tx -dir -threads 2 -inserts 100 -latm tx : : : nested_tx_dir_tx_t2_i100 ]
 
             [ run stm : -bench rbtree -dir -threads 4 -inserts 100 : : : rbtree_dir_t4_i100 ]
 
@@ -263,10 +249,23 @@
             # 11 [sig] isolated_composed_int_lock_def_t2 3660 _cygtls::handle_except ions: Error while dumping state (probably corrupted stack)
             [ run stm : -bench isolated_composed_int_lock2 -dir -threads 2 -inserts 100 -latm full : : : isolated_composed_int_lock2_dir_full_t2_i100 ]
 
+ ########### fails sometimes
+ [ run stm : -bench ll -def -threads 2 -inserts 100 -latm tm : : : ll_def_tm_t2_i100 ]
+
+ ########### fails sometimes
+ #assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 52
+ [ run stm : -bench linkedlist -def -threads 4 -inserts 100 : : : linkedlist_def_t4_i100 ]
     ;
     
     alias failures
         :
+ ########### fails with CHECK all-modes
+ # /bin/sh: line 4: 4072 Aborted (core dumped) "bin/lit_def_t2.test/gcc-3.4.4/debug/threading-multi/lit_def_t2.exe" > "bin/lit_def_t2.test/gcc-3.4.4/debug/threading-multi/lit_def_t2.output" 2>&1
+ ########### deadlock sometimes without CHECK. killed after 0:40. 00% CPU
+ [ run stm : -bench lit_example -def -threads 2 -inserts 100 -latm full : : : lit_example_def_full_t2_i100 ]
+ ########### fails
+ [ run stm : -bench lit_example -def -threads 2 -inserts 100 -latm tm : : : lit_example_def_tm_t2_i100 ]
+
             ########### fails
             # /bin/sh: line 4: 2944 Aborted (core dumped) "bin/ht_def_t2_i1000.test/gcc-3.4.4/debug/threading-multi/ht_def_t2_i1000.exe" > "bin/ht_def_t2_i1000.test/gcc-3.4.4/debug/threading-multi/ht_def_t2_i1000.output" 2>&1
             # Rounding max threads to the next multiple of 4 (4).
@@ -299,7 +298,7 @@
             # /bin/sh: line 4: 4772 Aborted (core dumped) "bin/gcc-3.4.4/debug/threading-multi/stm.exe" -bench isolated_composed_int_lock -def -threads 2 -inserts 100 -latm tx > "bin/isolated_composed_int_lock_def_tx_t2_i100.test/gcc-3.4.4/debug/threading-multi/isolated_composed_int_lock_def_tx_t2_i100.output" 2>&1
             [ run stm : -bench isolated_composed_int_lock -def -threads 2 -inserts 100 -latm tx : : : isolated_composed_int_lock_def_tx_t2_i100 ]
 
- ########### fails
+ ########### deadlock
             #/bin/sh: line 4: 4536 Aborted (core dumped) "bin/gcc-3.4.4/debug/threading-multi/stm.exe" -bench isolated_composed_int_lock2 -def -threads 2 -inserts 100 -latm full > "bin/isolated_composed_int_lock2_def_full_t2_i100.test/gcc-3.4.4/debug/threading-multi/isolated_composed_int_lock2_def_full_t2_i100.output" 2>&1
             #====== BEGIN OUTPUT ======
             #61 i= 0
@@ -366,8 +365,15 @@
             [ run stm : -bench using_linkedlist -dir -threads 2 -inserts 100 -latm tx : : : using_linkedlist_dir_tx_t2_i100 ]
 
             ########### fails
- #[ run stm : -bench tx_linear_lock -def -threads 2 -inserts 100 -latm tm : : : tx_linear_lock_def_tm_t2_i100 ]
+ [ run stm : -bench tx_linear_lock -def -threads 2 -inserts 100 -latm tm : : : tx_linear_lock_def_tm_t2_i100 ]
 
+ ########### fails
+ [ run stm : -bench isolated_composed_int_lock -dir -threads 2 -inserts 100 -latm tm : : : isolated_composed_int_lock_dir_tm_t2_i100 ]
+ ########### fails
+ [ run stm : -bench isolated_composed_int_lock -dir -threads 2 -inserts 100 -latm tx : : : isolated_composed_int_lock_dir_tx_t2_i100 ]
+
+ ########### fails
+ [ run stm : -bench lit_example -dir -threads 2 -inserts 100 -latm tm : : : lit_example_dir_tm_t2_i100 ]
     ;
 
     exe perf_counter : ../example/counter.cpp ;

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -33,6 +33,7 @@
 #include <iostream>
 #include "isolatedComposedIntLockInTx.h"
 #include <boost/stm/transaction.hpp>
+#include <boost/stm/synch.hpp>
 #include "main.h"
 
 static boost::stm::native_trans<int> gInt;
@@ -43,6 +44,7 @@
 #endif
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
+using namespace boost;
 
 static native_trans<int> globalInt;
 
@@ -61,19 +63,21 @@
       {
          try
          {
- transaction::lock_(lock1);
+ {
+ stm::lock_guard<latm::mutex_type> lk(lock1);
             ++gInt.value();
             cout << "\t" << gInt.value() << endl;
- transaction::unlock_(lock1);
+ }
 
             SLEEP(1000);
             // do nothing on purpose, allowing other threads time to see
             // intermediate state IF they can get lock1 (they shouldn't)
 
- transaction::lock_(lock1);
+ {
+ stm::lock_guard<latm::mutex_type> lk(lock1);
             --gInt.value();
             cout << "\t" << gInt.value() << endl;
- transaction::unlock_(lock1);
+ }
 
             t.end();
             SLEEP(1000);
@@ -110,9 +114,10 @@
 
    for (int i = startingValue; i < 100*endingValue; ++i)
    {
- transaction::lock_(lock1);
+ {
+ stm::lock_guard<latm::mutex_type> lk(lock1);
       cout << gInt.value() << endl;
- transaction::unlock_(lock1);
+ }
       SLEEP(10); // do nothing on purpose
    }
 

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -33,6 +33,7 @@
 #include <iostream>
 #include "isolatedComposedIntLockInTx.h"
 #include <boost/stm/transaction.hpp>
+#include <boost/stm/synch.hpp>
 #include "main.h"
 
 static boost::stm::native_trans<int> gInt;
@@ -46,6 +47,7 @@
 #endif
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
+using namespace boost;
 
 ///////////////////////////////////////////////////////////////////////////////
 static void* Test1(void *threadId)
@@ -65,19 +67,21 @@
          t.lock_conflict(&lock1);
          try
          {
- transaction::lock_(lock1);
+ {
+ stm::lock_guard<latm::mutex_type> lk(lock1);
             ++gInt.value();
             cout << "\t" << gInt.value() << endl;
- transaction::unlock_(lock1);
+ }
 
             SLEEP(50);
             // do nothing on purpose, allowing other threads time to see
             // intermediate state IF they can get lock1 (they shouldn't)
 
- transaction::lock_(lock1);
+ {
+ stm::lock_guard<latm::mutex_type> lk(lock1);
             --gInt.value();
             cout << "\t" << gInt.value() << endl;
- transaction::unlock_(lock1);
+ }
 
             t.end();
             SLEEP(50);

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -33,6 +33,7 @@
 #include <iostream>
 #include "isolatedInt.h"
 #include <boost/stm/transaction.hpp>
+#include <boost/stm/synch.hpp>
 #include "main.h"
 
 static boost::stm::native_trans<int> gInt;
@@ -44,6 +45,7 @@
 #endif
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
+using namespace boost;
 
 static native_trans<int> globalInt;
 
@@ -75,14 +77,15 @@
             // global memory (gInt), its state must be updated to
             // reflect all changes made previously inside the tx
             //-------------------------------------------------------
- transaction::lock_(lock1);
+ {
+ stm::lock_guard<latm::mutex_type> lk(lock1);
             cout << gInt.value() << endl;
 
             ++gInt.value();
 
             if (oldVal + 2 != gInt.value()) cout << "invariant violated" << endl;
 
- transaction::unlock_(lock1);
+ }
 
             //-------------------------------------------------------
             // now again access gInt via tx. tx should access the

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -33,6 +33,7 @@
 #include <iostream>
 #include "litExample.h"
 #include <boost/stm/transaction.hpp>
+#include <boost/stm/synch.hpp>
 #include "main.h"
 
 #ifndef BOOST_STM_USE_BOOST_MUTEX
@@ -48,6 +49,7 @@
 #endif
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
+using namespace boost;
 
 static native_trans<int> *arr1, *arr2, *arr3, *arr4, *arr5, *arr6, *arr7, *arr8;
 
@@ -62,32 +64,29 @@
 
 static void inc2()
 {
- transaction::lock_(L2);
+ stm::lock_guard<latm::mutex_type> lk(L2);
    for (int i = 0; i < kMaxArrSize; ++i)
    {
       ++arr2[i].value();
    }
- transaction::unlock_(L2);
 }
 
 static void inc3()
 {
- transaction::lock_(L3);
+ stm::lock_guard<latm::mutex_type> lk(L3);
    for (int i = 0; i < kMaxArrSize; ++i)
    {
       ++arr3[i].value();
    }
- transaction::unlock_(L3);
 }
 
 static void inc4()
 {
- transaction::lock_(L4);
+ stm::lock_guard<latm::mutex_type> lk(L4);
    for (int i = 0; i < kMaxArrSize; ++i)
    {
       ++arr4[i].value();
    }
- transaction::unlock_(L4);
 }
 
 
@@ -139,12 +138,11 @@
    if (work3) return;
    work3 = true;
 
- transaction::lock_(L8);
+ stm::lock_guard<latm::mutex_type> lk(L8);
    for (int i = 0; i < kMaxArrSize; ++i)
    {
       ++arr8[i].value();
    }
- transaction::unlock_(L8);
 }
 #endif
 static void* tx1(void *threadId)

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -33,6 +33,7 @@
 #include <iostream>
 #include "lotExample.h"
 #include <boost/stm/transaction.hpp>
+#include <boost/stm/synch.hpp>
 #include "main.h"
 
 #ifndef BOOST_STM_USE_BOOST_MUTEX
@@ -53,6 +54,7 @@
 #endif
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
+using namespace boost;
 
 static native_trans<int> *arr1, *arr2, *arr3, *arr4, *arr5, *arr6, *arr7, *arr8; //, *arr9;
 
@@ -113,12 +115,11 @@
 
    for (int iters = 0; iters < iterations; ++iters)
    {
- transaction::lock_(L8);
+ stm::lock_guard<latm::mutex_type> lk(L8);
        for (int i = 0; i < kMaxArrSize; ++i)
        {
          ++arr8[i].value();
        }
- transaction::unlock_(L8);
    }
 }
 #endif
@@ -130,12 +131,11 @@
 
    for (int iters = 0; iters < iterations; ++iters)
    {
- transaction::lock_(L9);
+ stm::lock_guard<latm::mutex_type> lk(L9);
        for (int i = 0; i < kMaxArrSize; ++i)
        {
          ++arr9[i].value();
        }
- transaction::unlock_(L9);
    }
 }
 #endif
@@ -258,9 +258,9 @@
 
    for (int iters = 0; iters < lockFactor*3000*iterations; ++iters)
    {
- transaction::lock_(L1); int sum = 0;
+ stm::lock_guard<latm::mutex_type> lk(L1);
+ int sum = 0;
       for (int i = 0; i < kMaxArrSize; ++i) sum += arr1[i].value();
- transaction::unlock_(L1);
    }
 
    endTimer = time(0);
@@ -282,9 +282,9 @@
 
    for (int iters = 0; iters < lockFactor*3000*iterations; ++iters)
    {
- transaction::lock_(L2); int sum = 0;
+ stm::lock_guard<latm::mutex_type> lk(L2);
+ int sum = 0;
       for (int i = 0; i < kMaxArrSize; ++i) sum += arr2[i].value();
- transaction::unlock_(L2);
    }
 
    endTimer = time(0);
@@ -306,9 +306,9 @@
 
    for (int iters = 0; iters < 10000*iterations; ++iters)
    {
- transaction::lock_(L3); int sum = 0;
+ stm::lock_guard<latm::mutex_type> lk(L3);
+ int sum = 0;
       for (int i = 0; i < kMaxArrSize; ++i) sum += arr3[i].value();
- transaction::unlock_(L3);
    }
 
    endTimer = time(0);

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -32,6 +32,7 @@
 
 #include <sstream>
 #include "nestedTxs.h"
+#include <boost/stm/synch.hpp>
 
 
 #ifndef BOOST_STM_USE_BOOST_MUTEX
@@ -47,6 +48,7 @@
 #endif
 
 using namespace boost::stm;
+using namespace boost;
 using namespace std;
 
 static native_trans<int> x = 0;
@@ -118,12 +120,10 @@
 {
    transaction::initialize_thread();
 
- transaction::lock_(&L2);
+ stm::lock_guard<latm::mutex_type> lk(L2);
 
    SLEEP(10000);
 
- transaction::unlock_(&L2);
-
    return 0;
 }
 
@@ -184,8 +184,8 @@
 
    SLEEP(1000);
 
- transaction::lock_(&L);
- transaction::lock_(&L3);
+ stm::lock_guard<latm::mutex_type> lk(L);
+ stm::lock_guard<latm::mutex_type> lk3(L3);
 
    try_atomic(t)
    {
@@ -197,8 +197,6 @@
 
    } before_retry {}
 
- transaction::unlock_(&L);
- transaction::unlock_(&L3);
 
    cout << "X: " << x.value() << endl;
 }
@@ -212,8 +210,8 @@
 
    SLEEP(1000);
 
- transaction::lock_(&L);
- transaction::lock_(&L3);
+ stm::unique_lock<latm::mutex_type> lk(L);
+ stm::lock_guard<latm::mutex_type> lk3(L3);
 
    try_atomic(t)
    {
@@ -221,15 +219,12 @@
       t.lock_conflict(&L2);
       t.lock_conflict(&L3);
 
- transaction::unlock_(&L);
+ lk.unlock();
 
       ++t.write(x);
 
    } before_retry {}
 
- transaction::unlock_(&L);
- transaction::unlock_(&L3);
-
    cout << "X: " << x.value() << endl;
 }
 

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -17,6 +17,7 @@
 
 #include "main.h"
 #include <boost/stm/transaction.hpp>
+#include <boost/stm/synch.hpp>
 #include <pthread.h>
 #include <fstream>
 
@@ -194,7 +195,8 @@
    bool lock_insert(list_node<T> const &rhs)
    {
       using namespace boost::stm;
- transaction::lock_(&list_lock_);
+ using namespace boost;
+ stm::lock_guard<latm::mutex_type> lk(list_lock_);
 
       list_node<T> *headP = &head_;
 
@@ -208,7 +210,6 @@
          {
             if (cur->value() == val)
             {
- transaction::unlock_(&list_lock_);
                return false;
             }
             else if (cur->value() > val || !cur->next()) break;
@@ -244,7 +245,6 @@
          head_.next(newNode);
       }
 
- transaction::unlock_(&list_lock_);
       return true;
    }
 
@@ -253,7 +253,8 @@
    bool lock_lookup(T const &val)
    {
       using namespace boost::stm;
- transaction::lock_(&list_lock_);
+ using namespace boost;
+ stm::lock_guard<latm::mutex_type> lk(list_lock_);
 
       LATM::list_node<T> *cur = &head_;
 
@@ -261,14 +262,12 @@
       {
          if (cur->value() == val)
          {
- transaction::unlock_(&list_lock_);
             return true;
          }
 
          if (0 == cur->next()) break;
       }
 
- transaction::unlock_(&list_lock_);
       return false;
    }
 

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -17,6 +17,7 @@
 
 #include "main.h"
 #include <boost/stm/transaction.hpp>
+#include <boost/stm/synch.hpp>
 #include <pthread.h>
 
 #include <fstream>
@@ -177,7 +178,8 @@
    bool lock_insert(list_node<T> const &rhs)
    {
       using namespace boost::stm;
- transaction::lock_(&list_lock_);
+ using namespace boost;
+ stm::lock_guard<latm::mutex_type> lk(list_lock_);
 
       list_node<T> *headP = &head_;
 
@@ -191,7 +193,6 @@
          {
             if (cur->value() == val)
             {
- transaction::unlock_(&list_lock_);
                return false;
             }
             else if (cur->value() > val || !cur->next()) break;
@@ -227,7 +228,6 @@
          head_.next(newNode);
       }
 
- transaction::unlock_(&list_lock_);
       return true;
    }
 
@@ -236,7 +236,8 @@
    bool lock_lookup(T const &val)
    {
       using namespace boost::stm;
- transaction::lock_(&list_lock_);
+ using namespace boost;
+ stm::lock_guard<latm::mutex_type> lk(list_lock_);
 
       LATM::list_node<T> *cur = &head_;
 
@@ -244,14 +245,12 @@
       {
          if (cur->value() == val)
          {
- transaction::unlock_(&list_lock_);
             return true;
          }
 
          if (0 == cur->next()) break;
       }
 
- transaction::unlock_(&list_lock_);
       return false;
    }
 

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -14,6 +14,7 @@
 #include <iostream>
 #include "txLinearLock.h"
 #include <boost/stm/transaction.hpp>
+#include <boost/stm/synch.hpp>
 #include "main.h"
 
 static boost::stm::native_trans<int> gInt1;
@@ -28,6 +29,7 @@
 
 ////////////////////////////////////////////////////////////////////////////
 using namespace std; using namespace boost::stm;
+using namespace boost;
 
 ///////////////////////////////////////////////////////////////////////////////
 static void* Test1(void *threadId)
@@ -47,17 +49,19 @@
 
          try
          {
- transaction::lock_(lock2);
+ {
+ stm::lock_guard<latm::mutex_type> lk(lock2);
             --gInt2.value();
             cout << "\tgInt2: " << gInt2.value() << endl;
- transaction::unlock_(lock2);
+ }
 
             SLEEP(1000);
 
- transaction::lock_(lock1);
+ {
+ stm::lock_guard<latm::mutex_type> lk(lock2);
             ++gInt1.value();
             cout << "\tgInt1: " << gInt1.value() << endl;
- transaction::unlock_(lock1);
+ }
 
             t.end();
             SLEEP(50);
@@ -96,16 +100,14 @@
    {
       SLEEP(1000);
 
- transaction::lock_(lock1);
- transaction::lock_(lock2);
+ stm::lock_guard<latm::mutex_type> lk(lock1);
+ stm::lock_guard<latm::mutex_type> lk2(lock2);
 
       --gInt1.value();
       ++gInt2.value();
       cout << "\t\tgInt1: " << gInt1.value() << endl;
       cout << "\t\tgInt2: " << gInt2.value() << endl;
 
- transaction::unlock_(lock2);
- transaction::unlock_(lock1);
    }
 
    //--------------------------------------------------------------------------

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -13,6 +13,7 @@
 
 #include <sstream>
 #include "usingLockTx.h"
+#include <boost/stm/synch.hpp>
 
 using namespace std;
 
@@ -33,6 +34,7 @@
 #endif
 
 using namespace boost::stm;
+using namespace boost;
 
 static native_trans<int> x = 0;
 static native_trans<int> y = 0;
@@ -286,11 +288,10 @@
 {
    transaction::initialize_thread();
 
- transaction::lock_(&L2);
+ stm::lock_guard<latm::mutex_type> lk(L2);
 
    SLEEP(10000);
 
- transaction::unlock_(&L2);
 
    return 0;
 }
@@ -336,8 +337,8 @@
 
    SLEEP(1000);
 
- transaction::lock_(&L);
- transaction::lock_(&L3);
+ stm::lock_guard<latm::mutex_type> lk(L);
+ stm::lock_guard<latm::mutex_type> lk3(L3);
 
    try_atomic(t)
    {
@@ -349,9 +350,6 @@
 
    } before_retry {}
 
- transaction::unlock_(&L);
- transaction::unlock_(&L3);
-
    cout << "X: " << x.value() << endl;
 }
 
@@ -364,8 +362,8 @@
 
    SLEEP(1000);
 
- transaction::lock_(&L);
- transaction::lock_(&L3);
+ stm::unique_lock<latm::mutex_type> lk(L);
+ stm::lock_guard<latm::mutex_type> lk3(L3);
 
    try_atomic(t)
    {
@@ -373,15 +371,12 @@
       t.lock_conflict(&L2);
       t.lock_conflict(&L3);
 
- transaction::unlock_(&L);
+ lk.unlock();
 
       ++t.write(x);
 
    } before_retry {}
 
- transaction::unlock_(&L);
- transaction::unlock_(&L3);
-
    cout << "X: " << x.value() << endl;
 }
 

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 10:41:22 EST (Sun, 08 Nov 2009)
@@ -19,6 +19,7 @@
 #include "testHT_latm.h"
 #include <boost/stm/transaction.hpp>
 #include <boost/stm/synch/auto_lock.hpp>
+#include <boost/stm/synch.hpp>
 #include <pthread.h>
 
 #include <fstream>
@@ -237,7 +238,8 @@
    bool lock_lookup(T const &val)
    {
       using namespace boost::stm;
- transaction::lock_(&list_lock_);
+ using namespace boost;
+ stm::lock_guard<latm::mutex_type> lk(list_lock_);
 
       LATM::list_node<T> *cur = &head_;
 
@@ -245,14 +247,12 @@
       {
          if (cur->value() == val)
          {
- transaction::unlock_(&list_lock_);
             return true;
          }
 
          if (0 == cur->next()) break;
       }
 
- transaction::unlock_(&list_lock_);
       return false;
    }
 


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