|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56951 - in sandbox/stm/branches/vbe: boost/stm boost/stm/detail boost/stm/memory_managers libs/stm/build libs/stm/src libs/stm/test
From: vicente.botet_at_[hidden]
Date: 2009-10-17 10:43:45
Author: viboes
Date: 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
New Revision: 56951
URL: http://svn.boost.org/trac/boost/changeset/56951
Log:
TBoost.STM vbe:
* Added synchro::lock,synchro::unlock, synchro::try_lock free functions
* Added of the free functions to pthread_mutex
* Added lockers synchro::lock_guard; synchro::lock_guard_if, synchro::unique_lock
* Use on the implementation of these free functions an/or the lockers
* trailing spaces
* boost::stm:: removal when not needed
* Warning Removal
* remove boost::stm:: prefix when not realy needed (this reduce the line length)
* replace http://www.boost.org/libs/stm by http://www.boost.org/libs/synchro on licencse comment
Text files modified:
sandbox/stm/branches/vbe/boost/stm/base_transaction_object.hpp | 19 -
sandbox/stm/branches/vbe/boost/stm/detail/auto_lock.hpp | 17
sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 9
sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp | 62 ++--
sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp | 66 +++--
sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp | 36 +-
sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp | 97 +++++---
sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp | 62 ++--
sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp | 60 ++--
sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp | 42 ++-
sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp | 299 ++++++++++++++------------
sandbox/stm/branches/vbe/boost/stm/memory_managers/base_memory_manager.hpp | 19 -
sandbox/stm/branches/vbe/boost/stm/synchro.hpp | 445 ++++++++++++++++++++++++++++++++-------
sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 92 ++++---
sandbox/stm/branches/vbe/libs/stm/build/Jamfile.v2 | 1
sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp | 14
sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 | 3
sandbox/stm/branches/vbe/libs/stm/test/globalIntArr.cpp | 4
sandbox/stm/branches/vbe/libs/stm/test/irrevocableInt.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp | 4
sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp | 7
sandbox/stm/branches/vbe/libs/stm/test/isolatedInt.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp | 9
sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp | 13
sandbox/stm/branches/vbe/libs/stm/test/lotExample.cpp | 24 +
sandbox/stm/branches/vbe/libs/stm/test/nestedTxs.cpp | 20
sandbox/stm/branches/vbe/libs/stm/test/pointer_test.cpp | 8
sandbox/stm/branches/vbe/libs/stm/test/smart.cpp | 23 +
sandbox/stm/branches/vbe/libs/stm/test/stm.cpp | 45 ++-
sandbox/stm/branches/vbe/libs/stm/test/testHT_latm.cpp | 4
sandbox/stm/branches/vbe/libs/stm/test/testHashMap.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/testHashMapAndLinkedListsWithLocks.cpp | 7
sandbox/stm/branches/vbe/libs/stm/test/testHashMapWithLocks.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/testInt.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/testLL_latm.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/testLinkedList.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.h | 12
sandbox/stm/branches/vbe/libs/stm/test/testPerson.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/testRBTree.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/testRBTree.h | 8
sandbox/stm/branches/vbe/libs/stm/test/transferFun.cpp | 2
sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp | 27 +
sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.h | 6
44 files changed, 969 insertions(+), 617 deletions(-)
Modified: sandbox/stm/branches/vbe/boost/stm/base_transaction_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/base_transaction_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/base_transaction_object.hpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -116,28 +116,15 @@
#if USE_STM_MEMORY_MANAGER
static void return_mem(void *mem, size_t size)
{
-#ifndef BOOST_STM_USE_BOOST_MUTEX
- lock(&transactionObjectMutex_);
+ synchro::lock_guard<Mutex> lock(transactionObjectMutex_);
memory_.returnChunk(mem, size);
- unlock(&transactionObjectMutex_);
-#else
- boost::lock_guard<boost::mutex> lock(transactionObjectMutex_);
- memory_.returnChunk(mem, size);
-#endif
}
static void* retrieve_mem(size_t size)
{
-#ifndef BOOST_STM_USE_BOOST_MUTEX
- lock(&transactionObjectMutex_);
- void *mem = memory_.retrieveChunk(size);
- unlock(&transactionObjectMutex_);
-#else
- boost::lock_guard<boost::mutex> lock(transactionObjectMutex_);
+ synchro::lock_guard<Mutex> lock(transactionObjectMutex_);
void *mem = memory_.retrieveChunk(size);
-#endif
-
- return mem;
+ return mem;
}
#endif
Modified: sandbox/stm/branches/vbe/boost/stm/detail/auto_lock.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/auto_lock.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/auto_lock.hpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -27,8 +27,8 @@
#define BOOST_STM_LOCK(a) boost::stm::transaction::lock_(a)
#define BOOST_STM_UNLOCK(a) boost::stm::transaction::unlock_(a)
#else
-#define BOOST_STM_LOCK(a) boost::stm::lock(a)
-#define BOOST_STM_UNLOCK(a) boost::stm::unlock(a)
+#define BOOST_STM_LOCK(a) boost::synchro::lock(a)
+#define BOOST_STM_UNLOCK(a) boost::synchro::unlock(a)
#endif
//---------------------------------------------------------------------------
@@ -102,7 +102,7 @@
for (size_t i = 0; i < timeOut; ++i)
{
- if (0 == trylock(lock_))
+ if (0 == synchro::try_lock(*lock_))
{
hasLock_ = true;
insert_into_threaded_lock_map(mutex);
@@ -117,9 +117,8 @@
void insert_into_threaded_lock_map(Mutex* mutex)
{
- lock(global_lock());
+ synchro::lock_guard<Mutex> lock_i(*global_lock());
threaded_locks().insert(ThreadedLockPair(THREAD_ID, mutex));
- unlock(global_lock());
}
void do_auto_lock(Mutex *mutex)
@@ -145,25 +144,23 @@
bool thread_has_lock(Mutex *rhs)
{
- lock(global_lock());
+ synchro::lock_guard<Mutex> lock_g(*global_lock());
for (ThreadedLockIter i = threaded_locks().begin();
i != threaded_locks().end(); ++i)
{
if (i->first == THREAD_ID && i->second == rhs)
{
- unlock(global_lock());
return true;
}
}
- unlock(global_lock());
return false;
}
void remove_thread_has_lock(Mutex *rhs)
{
- lock(global_lock());
+ synchro::lock_guard<Mutex> lock_g(*global_lock());
for (ThreadedLockIter i = threaded_locks().begin();
i != threaded_locks().end(); ++i)
@@ -174,8 +171,6 @@
break;
}
}
-
- unlock(global_lock());
}
static Mutex *global_lock()
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-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -79,11 +79,18 @@
#define MAP_THREAD_BOOL_CONTAINER 1
#define USING_SHARED_FORCED_TO_ABORT 1
+
+///////////////////////////////////////////////////////////////////////////////
+// Define BOOST_STM_USE_BOOST when you want STM uses BOOST internally
+
+#define BOOST_STM_USE_BOOST 1
+
+#ifdef BOOST_STM_USE_BOOST
//#define BOOST_STM_BLOOM_FILTER_USE_DYNAMIC_BITSET 1
//#define BOOST_STM_USE_BOOST_SLEEP 1
//#define BOOST_STM_USE_BOOST_THREAD_ID 1
//#define BOOST_STM_USE_BOOST_MUTEX 1
-
+#endif
#define BOOST_STM_NO_PARTIAL_SPECIALIZATION 1
///////////////////////////////////////////////////////////////////////////////
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-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -58,8 +58,8 @@
//--------------------------------------------------------------------------
if (latmLockedLocks_.empty())
{
- lock(general_lock());
- lock(inflight_lock());
+ synchro::lock(*general_lock());
+ synchro::lock(*inflight_lock());
std::list<transaction*> txList;
for (InflightTxes::iterator i = transactionsInFlight_.begin();
@@ -74,8 +74,8 @@
}
else
{
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
return false;
}
}
@@ -85,14 +85,14 @@
(*it)->force_to_abort();
}
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
}
try { latmLockedLocks_.insert(mutex); }
catch (...)
{
- unlock(inflight_lock());
+ synchro::unlock(*inflight_lock());
throw;
}
@@ -113,14 +113,14 @@
t->add_to_obtained_locks(mutex);
t->commit_deferred_update_tx();
- lock(latm_lock());
+ synchro::lock(*latm_lock());
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(latm_lock());
+ synchro::unlock(*latm_lock());
// TBR if (hadLock) return 0;
// TBR else return lock(mutex);
if (hadLock) return 0;
- else lock(mutex);
+ else synchro::lock(*mutex);
return 0;
}
@@ -129,9 +129,9 @@
{
// TBR int val = lock(mutex);
// TBR if (0 != val) return val;
- lock(mutex);
+ synchro::lock(*mutex);
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
try
{
@@ -142,16 +142,16 @@
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
//-----------------------------------------------------------------------
// we weren't able to do the core lock work, unlock our mutex and sleep
//-----------------------------------------------------------------------
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
SLEEP(cm_lock_sleep_time());
waitTime += cm_lock_sleep_time();
@@ -159,7 +159,7 @@
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
return 0;
}
@@ -177,18 +177,18 @@
t->add_to_obtained_locks(mutex);
t->commit_deferred_update_tx();
- lock(latm_lock());
+ synchro::lock(*latm_lock());
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(latm_lock());
+ synchro::unlock(*latm_lock());
if (hadLock) return 0;
- else return trylock(mutex);
+ else return synchro::try_lock(*mutex);
}
- int val = trylock(mutex);
+ int val = synchro::try_lock(*mutex);
if (0 != val) return val;
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
try
{
@@ -197,20 +197,20 @@
//-----------------------------------------------------------------------
if (!def_do_core_full_pthread_lock_mutex(mutex, 0, 0))
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
return -1;
}
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
// note: we do not release the transactionsInFlightMutex - this will prevents
// new transactions from starting until this lock is released
return 0;
@@ -221,7 +221,7 @@
//----------------------------------------------------------------------------
inline int transaction::def_full_pthread_unlock_mutex(Mutex *mutex)
{
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
bool hasLock = true;
if (transaction* t = get_inflight_tx_of_same_thread(false))
@@ -240,14 +240,14 @@
latmLockedLocks_.erase(mutex);
- if (latmLockedLocks_.empty()) unlock(inflight_lock());
+ if (latmLockedLocks_.empty()) synchro::unlock(*inflight_lock());
latmLockedLocksOfThreadMap_.erase(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
// TBR if (hasLock) return unlock(mutex);
// TBR else return 0;
- if (hasLock) unlock(mutex);
+ if (hasLock) synchro::unlock(*mutex);
return 0;
}
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-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -107,14 +107,17 @@
bool hadLock = t->is_currently_locked_lock(mutex);
t->add_to_currently_locked_locks(mutex);
- lock(latm_lock());
+ {
+ synchro::lock_guard<Mutex> lock_l(*latm_lock());
+ //synchro::lock(*latm_lock());
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(latm_lock());
+ //synchro::unlock(*latm_lock());
+ }
// TBR if (hadLock) return 0;
// TBR else return lock(mutex);
if (hadLock) return 0;
- else lock(mutex);
+ else synchro::lock(*mutex);
return 0;
}
@@ -124,9 +127,11 @@
{
// TRR int val = lock(mutex);
// TRR if (0 != val) return val;
- lock(mutex);
-
- lock(&latmMutex_);
+ {
+ synchro::lock_guard<Mutex> lock_m(*latm_lock());
+ synchro::lock_guard<Mutex> lock_l(latmMutex_);
+ //synchro::lock(*mutex);
+ //synchro::lock(latmMutex_);
try
{
@@ -138,16 +143,17 @@
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
//-----------------------------------------------------------------------
// we weren't able to do the core lock work, unlock our mutex and sleep
//-----------------------------------------------------------------------
- unlock(mutex);
- unlock(&latmMutex_);
+ //synchro::unlock(*mutex);
+ //synchro::unlock(latmMutex_);
+ }
SLEEP(cm_lock_sleep_time());
waitTime += cm_lock_sleep_time();
@@ -155,7 +161,7 @@
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
return 0;
}
@@ -174,18 +180,25 @@
bool hadLock = t->is_currently_locked_lock(mutex);
t->add_to_currently_locked_locks(mutex);
- lock(latm_lock());
+ {
+ synchro::lock_guard<Mutex> lock_l(*latm_lock());
+ //synchro::lock(*latm_lock());
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(latm_lock());
+ //synchro::unlock(*latm_lock());
+ }
if (hadLock) return 0;
- else return trylock(mutex);
+ else return synchro::try_lock(*mutex);
}
- int val = trylock(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;
- lock(&latmMutex_);
+ //synchro::lock(latmMutex_);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_);
try
{
@@ -194,20 +207,20 @@
//-----------------------------------------------------------------------
if (!def_do_core_tm_conflicting_lock_pthread_lock_mutex(mutex, 0, 0))
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex); // BUG ???
+ //synchro::unlock(latmMutex_);
return -1;
}
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex); // BUG ???
+ //synchro::unlock(latmMutex_);
throw;
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ //synchro::unlock(latmMutex_);
// note: we do not release the transactionsInFlightMutex - this will prevents
// new transactions from starting until this lock is released
return 0;
@@ -218,8 +231,10 @@
//----------------------------------------------------------------------------
inline int transaction::def_tm_conflicting_lock_pthread_unlock_mutex(Mutex *mutex)
{
- lock(&latmMutex_);
bool hasLock = true;
+ {
+ synchro::lock_guard<Mutex> lock_l(latmMutex_);
+ //synchro::lock(latmMutex_);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
@@ -244,15 +259,16 @@
{
latmLockedLocks_.erase(mutex);
- if (latmLockedLocks_.empty()) unlock(inflight_lock());
+ if (latmLockedLocks_.empty()) synchro::unlock(*inflight_lock());
}
latmLockedLocksOfThreadMap_.erase(mutex);
- unlock(&latmMutex_);
+ //synchro::unlock(latmMutex_);
+ }
// TBR if (hasLock) return unlock(mutex);
// TBR else return 0;
- if (hasLock) unlock(mutex);
+ if (hasLock) synchro::unlock(*mutex);
return 0;
}
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-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -151,27 +151,27 @@
if (!t->is_currently_locked_lock(mutex))
{
- lock(mutex); // TBR if (0 != lock(mutex)) return -1;
+ synchro::lock(*mutex); // TBR if (0 != lock(mutex)) return -1;
}
t->add_to_currently_locked_locks(mutex);
t->add_to_obtained_locks(mutex);
t->commit_deferred_update_tx();
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
def_do_core_tx_conflicting_lock_pthread_lock_mutex
(mutex, 0, 0, true);
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
return 0;
}
for (;;)
{
- lock(mutex); // TBR int val = lock(mutex);
+ synchro::lock(*mutex); // TBR int val = lock(mutex);
// TBR if (0 != val) return val;
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
try
{
@@ -183,16 +183,16 @@
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
//-----------------------------------------------------------------------
// we weren't able to do the core lock work, unlock our mutex and sleep
//-----------------------------------------------------------------------
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
SLEEP(cm_lock_sleep_time());
waitTime += cm_lock_sleep_time();
@@ -200,7 +200,7 @@
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
// note: we do not release the transactionsInFlightMutex - this will prevents
// new transactions from starting until this lock is released
@@ -218,10 +218,10 @@
bool txIsIrrevocable = false;
- int val = trylock(mutex);
+ int val = synchro::try_lock(*mutex);
if (0 != val) return val;
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
@@ -239,20 +239,20 @@
//-----------------------------------------------------------------------
if (!def_do_core_tx_conflicting_lock_pthread_lock_mutex(mutex, 0, 0, txIsIrrevocable))
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
return -1;
}
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
// note: we do not release the transactionsInFlightMutex - this will prevents
// new transactions from starting until this lock is released
@@ -306,7 +306,7 @@
// TBR if (hasLock) return unlock(mutex);
// TBR else return 0;
- if (hasLock) unlock(mutex);
+ if (hasLock) synchro::unlock(*mutex);
return 0;
}
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-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -58,8 +58,12 @@
//--------------------------------------------------------------------------
if (latmLockedLocks_.empty())
{
- lock(general_lock());
- lock(inflight_lock());
+
+ {
+ //synchro::lock_guard<Mutex> lock_g(*general_lock());
+ synchro::lock(*general_lock());
+ //synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ synchro::lock(*inflight_lock());
std::list<transaction*> txList;
for (InflightTxes::iterator i = transactionsInFlight_.begin();
@@ -74,8 +78,8 @@
}
else
{
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
return false;
}
}
@@ -90,8 +94,9 @@
//-----------------------------------------------------------------------
thread_conflicting_mutexes_set_all(true);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
+ }
//-----------------------------------------------------------------------
// now we must stall until all in-flight transactions are gone, otherwise
@@ -100,11 +105,13 @@
while (!transactionsInFlight_.empty()) { SLEEP(10); }
}
- try { latmLockedLocks_.insert(mutex); }
+ try {
+ latmLockedLocks_.insert(mutex); }
catch (...)
{
- unlock(general_lock());
- unlock(inflight_lock());
+ // BUG ???
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
throw;
}
@@ -127,41 +134,45 @@
// this method locks LATM and keeps it locked upon returning if param true
wait_until_all_locks_are_released(true);
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(latm_lock());
+ synchro::unlock(*latm_lock());
if (hadLock) return 0;
- else lock(mutex);
+ else synchro::lock(*mutex);
return 0;
}
int waitTime = 0, aborted = 0;
for (;;)
{
+ {
// TBR int val = lock(mutex);
// TBR if (0 != val) return val;
- lock(mutex);
+ //synchro::lock(*mutex);
+ synchro::lock_guard<Mutex> lock_m(*mutex);
- lock(&latmMutex_);
+ //synchro::lock(latmMutex_);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_);
- try
- {
+ //try
+ //{
//--------------------------------------------------------------------
// if we are able to do the core lock work, break
//--------------------------------------------------------------------
if (dir_do_core_full_pthread_lock_mutex(mutex, waitTime, aborted)) break;
- }
- catch (...)
- {
- unlock(mutex);
- unlock(&latmMutex_);
- throw;
- }
+ //}
+ //catch (...)
+ //{
+ //synchro::unlock(*mutex);
+ //synchro::unlock(latmMutex_);
+ //throw;
+ //}
//-----------------------------------------------------------------------
// we weren't able to do the core lock work, unlock our mutex and sleep
//-----------------------------------------------------------------------
- unlock(mutex);
- unlock(&latmMutex_);
+ //synchro::unlock(*mutex);
+ //synchro::unlock(latmMutex_);
+ }
SLEEP(cm_lock_sleep_time());
waitTime += cm_lock_sleep_time();
@@ -169,7 +180,7 @@
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
return 0;
}
@@ -189,16 +200,19 @@
// this method locks LATM and keeps it locked upon returning if param true
wait_until_all_locks_are_released(true);
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(latm_lock());
+ synchro::unlock(*latm_lock());
if (hadLock) return 0;
- else return trylock(mutex);
+ else return synchro::try_lock(*mutex);
}
- int val = trylock(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;
- lock(&latmMutex_);
+ //synchro::lock(latmMutex_);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_);
try
{
@@ -207,20 +221,20 @@
//-----------------------------------------------------------------------
if (!dir_do_core_full_pthread_lock_mutex(mutex, 0, 0))
{
- unlock(mutex);
- unlock(&latmMutex_);
+ //synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
return -1;
}
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ //synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ //synchro::unlock(latmMutex_);
// note: we do not release the transactionsInFlightMutex - this will prevents
// new transactions from starting until this lock is released
return 0;
@@ -231,8 +245,10 @@
//----------------------------------------------------------------------------
inline int transaction::dir_full_pthread_unlock_mutex(Mutex *mutex)
{
- lock(&latmMutex_);
bool hasLock = true;
+ {
+ //synchro::lock(latmMutex_);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
@@ -252,19 +268,20 @@
if (latmLockedLocks_.empty())
{
- lock(general_lock());
+ synchro::lock_guard<Mutex> lock_l(*general_lock());
+ //synchro::lock(*general_lock());
thread_conflicting_mutexes_set_all(false);
- unlock(general_lock());
+ //synchro::unlock(*general_lock());
}
latmLockedLocksOfThreadMap_.erase(mutex);
- unlock(&latmMutex_);
-
+ //synchro::unlock(latmMutex_);
+ }
// TBR if (hasLock) return unlock(mutex);
// TBR else return 0;
- if (hasLock) unlock(mutex);
+ if (hasLock) synchro::unlock(*mutex);
return 0;
}
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-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -66,8 +66,8 @@
//--------------------------------------------------------------------------
if (latmLockedLocks_.empty())
{
- lock(general_lock());
- lock(inflight_lock());
+ synchro::lock(*general_lock());
+ synchro::lock(*inflight_lock());
std::list<transaction*> txList;
for (InflightTxes::iterator i = transactionsInFlight_.begin();
@@ -82,8 +82,8 @@
}
else
{
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
return false;
}
}
@@ -98,8 +98,8 @@
//-----------------------------------------------------------------------
thread_conflicting_mutexes_set_all(true);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
//-----------------------------------------------------------------------
// now we must stall until all in-flight transactions are gone, otherwise
@@ -123,10 +123,10 @@
{
transaction::must_be_in_tm_conflicting_lock_set(mutex);
t->make_isolated();
- lock(latm_lock());
+ synchro::lock(*latm_lock());
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(latm_lock());
- lock(mutex);
+ synchro::unlock(*latm_lock());
+ synchro::lock(*mutex);
return 0;
}
@@ -136,9 +136,9 @@
{
// TBR int val = lock(mutex);
// TBR if (0 != val) return val;
- lock(mutex);
+ synchro::lock(*mutex);
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
try
{
@@ -150,16 +150,16 @@
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
//-----------------------------------------------------------------------
// we weren't able to do the core lock work, unlock our mutex and sleep
//-----------------------------------------------------------------------
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
SLEEP(cm_lock_sleep_time());
waitTime += cm_lock_sleep_time();
@@ -167,7 +167,7 @@
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
return 0;
}
@@ -181,16 +181,16 @@
{
transaction::must_be_in_tm_conflicting_lock_set(mutex);
t->make_isolated();
- lock(latm_lock());
+ synchro::lock(*latm_lock());
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(latm_lock());
- return trylock(mutex);
+ synchro::unlock(*latm_lock());
+ return synchro::try_lock(*mutex);
}
- int val = trylock(mutex);
+ int val = synchro::try_lock(*mutex);
if (0 != val) return val;
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
try
{
@@ -199,20 +199,20 @@
//-----------------------------------------------------------------------
if (!dir_do_core_tm_conflicting_lock_pthread_lock_mutex(mutex, 0, 0))
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
return -1;
}
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
// note: we do not release the transactionsInFlightMutex - this will prevents
// new transactions from starting until this lock is released
return 0;
@@ -223,7 +223,7 @@
//----------------------------------------------------------------------------
inline int transaction::dir_tm_conflicting_lock_pthread_unlock_mutex(Mutex *mutex)
{
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
bool hasLock = true;
if (transaction* t = get_inflight_tx_of_same_thread(false))
@@ -251,20 +251,20 @@
if (latmLockedLocks_.empty())
{
- lock(general_lock());
+ synchro::lock(*general_lock());
thread_conflicting_mutexes_set_all(false);
- unlock(general_lock());
+ synchro::unlock(*general_lock());
}
}
latmLockedLocksOfThreadMap_.erase(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
//if (hasLock) return unlock(mutex);
//else return 0;
- if (hasLock) unlock(mutex);
+ if (hasLock) synchro::unlock(*mutex);
return 0;
}
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-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -51,8 +51,8 @@
// set. do not keep in-flight transactions blocked once the transactions have
// been processed.
//--------------------------------------------------------------------------
- lock(general_lock());
- lock(inflight_lock());
+ synchro::lock(*general_lock());
+ synchro::lock(*inflight_lock());
std::list<transaction *> txList;
std::set<size_t> txThreadId;
@@ -75,8 +75,8 @@
}
else
{
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
return false;
}
}
@@ -112,8 +112,8 @@
throw;
}
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
//-----------------------------------------------------------------------
// now wait until all the txs which conflict with this mutex are no longer
@@ -123,8 +123,8 @@
{
bool conflictingTxInFlight = false;
- lock(general_lock());
- lock(inflight_lock());
+ synchro::lock(*general_lock());
+ synchro::lock(*inflight_lock());
for (InflightTxes::iterator i = transactionsInFlight_.begin();
i != transactionsInFlight_.end(); ++i)
@@ -137,16 +137,16 @@
}
}
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
if (conflictingTxInFlight) SLEEP(10);
else return true;
}
}
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
return true;
}
@@ -186,16 +186,16 @@
if (!t->is_currently_locked_lock(mutex))
{
// TBR if (0 != lock(mutex)) return -1;
- lock(mutex);
+ synchro::lock(*mutex);
}
t->add_to_currently_locked_locks(mutex);
t->add_to_obtained_locks(mutex);
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
def_do_core_tx_conflicting_lock_pthread_lock_mutex
(mutex, 0, 0, true);
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
return 0;
}
@@ -204,9 +204,9 @@
{
// TBR int val = lock(mutex);
// TBR if (0 != val) return val;
- lock(mutex);
+ synchro::lock(*mutex);
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
try
{
@@ -218,16 +218,16 @@
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
//-----------------------------------------------------------------------
// we weren't able to do the core lock work, unlock our mutex and sleep
//-----------------------------------------------------------------------
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
SLEEP(cm_lock_sleep_time());
waitTime += cm_lock_sleep_time();
@@ -235,7 +235,7 @@
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
// note: we do not release the transactionsInFlightMutex - this will prevents
// new transactions from starting until this lock is released
@@ -252,10 +252,10 @@
bool txIsIrrevocable = false;
- int val = trylock(mutex);
+ int val = synchro::try_lock(*mutex);
if (0 != val) return val;
- lock(&latmMutex_);
+ synchro::lock(latmMutex_);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
@@ -272,20 +272,20 @@
//-----------------------------------------------------------------------
if (!dir_do_core_tx_conflicting_lock_pthread_lock_mutex(mutex, 0, 0, txIsIrrevocable))
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
return -1;
}
}
catch (...)
{
- unlock(mutex);
- unlock(&latmMutex_);
+ synchro::unlock(*mutex);
+ synchro::unlock(latmMutex_);
throw;
}
latmLockedLocksOfThreadMap_[mutex] = THREAD_ID;
- unlock(&latmMutex_);
+ synchro::unlock(latmMutex_);
// note: we do not release the transactionsInFlightMutex - this will prevents
// new transactions from starting until this lock is released
@@ -330,7 +330,7 @@
// TBR if (hasLock) return unlock(mutex);
// TBR else return 0;
- if (hasLock) unlock(mutex);
+ if (hasLock) synchro::unlock(*mutex);
return 0;
}
}}
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-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -50,13 +50,13 @@
{
while (true)
{
- lock(latm_lock());
+ synchro::lock(*latm_lock());
if (latmLockedLocks_.empty()) break;
- unlock(latm_lock());
+ synchro::unlock(*latm_lock());
SLEEP(10);
}
- if (!keepLatmLocked) unlock(latm_lock());
+ if (!keepLatmLocked) synchro::unlock(*latm_lock());
}
//----------------------------------------------------------------------------
@@ -271,27 +271,31 @@
{
if (!doing_tm_lock_protection()) return;
- lock(&latmMutex_);
+ //synchro::lock(latmMutex_);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_);
//-------------------------------------------------------------------------
// insert can throw an exception
//-------------------------------------------------------------------------
- try { tmConflictingLocks_.insert(inLock); }
- catch (...)
- {
- unlock(&latmMutex_);
- throw;
- }
- unlock(&latmMutex_);
+ //try {
+ tmConflictingLocks_.insert(inLock);
+ //}
+ //catch (...)
+ //{
+ // synchro::unlock(latmMutex_);
+ //throw;
+ //}
+ //synchro::unlock(latmMutex_);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
inline void boost::stm::transaction::clear_tm_conflicting_locks()
{
- lock(&latmMutex_);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_);
+ //synchro::lock(latmMutex_);
tmConflictingLocks_.clear();
- unlock(&latmMutex_);
+ //synchro::unlock(latmMutex_);
}
//----------------------------------------------------------------------------
@@ -342,9 +346,10 @@
//----------------------------------------------------------------------------
inline void boost::stm::transaction::clear_tx_conflicting_locks()
{
- lock(general_lock());
+ synchro::lock_guard<Mutex> lock_l(*general_lock());
+ //synchro::lock(*general_lock());
get_tx_conflicting_locks().clear();
- unlock(general_lock());
+ //synchro::unlock(*general_lock());
}
//----------------------------------------------------------------------------
@@ -509,7 +514,8 @@
inline boost::stm::transaction* boost::stm::transaction::get_inflight_tx_of_same_thread
(bool hasTxInFlightMutex)
{
- if (!hasTxInFlightMutex) lock(inflight_lock());
+ synchro::lock_guard_if<Mutex> lock_l(*general_lock(), !hasTxInFlightMutex);
+ //if (!hasTxInFlightMutex) synchro::lock(*inflight_lock());
for (InflightTxes::iterator i = transactionsInFlight_.begin();
i != transactionsInFlight_.end(); ++i)
@@ -523,12 +529,12 @@
//--------------------------------------------------------------------
if (t->thread_id() == THREAD_ID)
{
- if (!hasTxInFlightMutex) unlock(inflight_lock());
+ //if (!hasTxInFlightMutex) synchro::unlock(*inflight_lock());
return t;
}
}
- if (!hasTxInFlightMutex) unlock(inflight_lock());
+ //if (!hasTxInFlightMutex) synchro::unlock(*inflight_lock());
return 0;
}
}}
Modified: sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -125,16 +125,19 @@
//-----------------------------------------------------------------------
while (true)
{
- lock(inflight_lock());
+ {
+ //lock(inflight_lock());
+ synchro::lock_guard<Mutex> lock_m(*inflight_lock());
if (!irrevocableTxInFlight())
{
tx_type(eIrrevocableTx);
- unlock(inflight_lock());
+ //unlock(inflight_lock());
return;
}
- unlock(inflight_lock());
+ //unlock(inflight_lock());
+ }
SLEEP(10);
cm_perform_irrevocable_tx_wait_priority_promotion(*this);
}
@@ -160,20 +163,24 @@
("aborting tx in make_isolated");
}
- lock(general_lock());
- lock(inflight_lock());
+ {
+ //lock(general_lock());
+ synchro::lock_guard<Mutex> lock_g(*general_lock());
+ //lock(inflight_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock());
if (!irrevocableTxInFlight() && canAbortAllInFlightTxs())
{
tx_type(eIrrevocableAndIsolatedTx);
abortAllInFlightTxs();
- unlock(general_lock());
- unlock(inflight_lock());
+ //unlock(general_lock());
+ //unlock(inflight_lock());
return;
}
- unlock(general_lock());
- unlock(inflight_lock());
+ //unlock(general_lock());
+ //unlock(inflight_lock());
+ }
//SLEEP(10);
cm_perform_isolated_tx_wait_priority_promotion(*this);
}
@@ -222,13 +229,17 @@
//--------------------------------------------------------------------------
// otherwise, force the tx to commit its writes/reads
//--------------------------------------------------------------------------
- while (0 != trylock(&transactionMutex_))
+ #if 0
+ while (0 != synchro::try_lock(&transactionMutex_))
{
bookkeeping_.inc_lock_convoy_ms(1);
SLEEP(1);
}
+ #endif
- lock_tx();
+ synchro::lock_guard<Mutex> lock_g(*general_lock());
+ synchro::lock_guard<Mutex> lock_m(*mutex());
+ //lock_tx();
//--------------------------------------------------------------------------
// this is a very important and subtle optimization. if the transaction is
@@ -238,12 +249,13 @@
//--------------------------------------------------------------------------
if (is_only_reading())
{
- unlock(general_lock());
- unlock_tx();
+ //unlock(general_lock());
+ //unlock_tx();
}
else
{
- lock(inflight_lock());
+ //lock(inflight_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock());
//-----------------------------------------------------------------------
// commit writes, clear new and deletes
@@ -255,9 +267,9 @@
deferredCommitTransactionNewMemory();
deferredCommitTransactionDeletedMemory();
- unlock_tx();
- unlock(general_lock());
- unlock(inflight_lock());
+ //unlock_tx();
+ //unlock(general_lock());
+ //unlock(inflight_lock());
}
//--------------------------------------------------------------------------
@@ -269,20 +281,20 @@
//-----------------------------------------------------------------------------
inline void transaction::lock_tx()
{
- while (0 != trylock(mutex()))
+ while (0 != synchro::try_lock(*mutex()))
{
SLEEP(1);
}
- hasMutex_ = 1;
+ //hasMutex_ = 1;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline void transaction::unlock_tx()
{
- unlock(mutex());
- hasMutex_ = 0;
+ synchro::unlock(*mutex());
+ //hasMutex_ = 0;
}
//--------------------------------------------------------------------------
@@ -294,14 +306,14 @@
i != tss_context_map_.end(); ++i)
{
if (i->first == threadId) continue;
- lock(i->second->mutex_);
+ synchro::lock(i->second->mutex_);
}
#else
for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
i != threadMutexes_.end(); ++i)
{
if (i->first == threadId) continue;
- lock(i->second);
+ synchro::lock(*(i->second));
}
#endif
}
@@ -314,14 +326,14 @@
i != tss_context_map_.end(); ++i)
{
if (i->first == threadId) continue;
- unlock(i->second->mutex_);
+ synchro::unlock(i->second->mutex_);
}
#else
for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
i != threadMutexes_.end(); ++i)
{
if (i->first == threadId) continue;
- unlock(i->second);
+ synchro::unlock(*(i->second));
}
#endif
}
@@ -334,16 +346,16 @@
for (tss_context_map_type::iterator i = tss_context_map_.begin();
i != tss_context_map_.end(); ++i)
{
- lock(i->second->mutex_);
+ synchro::lock(i->second->mutex_);
}
#else
for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
i != threadMutexes_.end(); ++i)
{
- lock(i->second);
+ synchro::lock(*(i->second));
}
#endif
- hasMutex_ = 1;
+ //hasMutex_ = 1;
}
//-----------------------------------------------------------------------------
@@ -358,16 +370,16 @@
for (tss_context_map_type::iterator i = tss_context_map_.begin();
i != tss_context_map_.end(); ++i)
{
- unlock(i->second->mutex_);
+ synchro::unlock(i->second->mutex_);
}
#else
for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
i != threadMutexes_.end(); ++i)
{
- unlock(i->second);
+ synchro::unlock(*(i->second));
}
#endif
- hasMutex_ = 0;
+ //hasMutex_ = 0;
}
//--------------------------------------------------------------------------
@@ -473,7 +485,8 @@
#endif
- hasMutex_(0), priority_(0),
+ //hasMutex_(0),
+ priority_(0),
state_(e_no_state),
reads_(0),
startTime_(time(0))
@@ -577,12 +590,15 @@
//-----------------------------------------------------------------------
#if PERFORMING_COMPOSITION
#ifdef USING_SHARED_FORCED_TO_ABORT
- lock(inflight_lock());
+ {
+ //lock(inflight_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock());
if (!otherInFlightTransactionsOfSameThreadNotIncludingThis(this))
{
unforce_to_abort();
}
- unlock(inflight_lock());
+ //unlock(inflight_lock());
+ }
#else
unforce_to_abort();
#endif
@@ -652,23 +668,27 @@
#if PERFORMING_LATM
while (true)
{
- lock(inflight_lock());
+ {
+ //lock(inflight_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock());
if (can_go_inflight() && !isolatedTxInFlight())
{
transactionsInFlight_.insert(this);
state_ = e_in_flight;
- unlock(inflight_lock());
+ //unlock(inflight_lock());
break;
}
- unlock(inflight_lock());
+ //unlock(inflight_lock());
+ }
SLEEP(10);
}
#else
- lock(inflight_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ //lock(inflight_lock());
transactionsInFlight_.insert(this);
- unlock(inflight_lock());
+ //unlock(inflight_lock());
state_ = e_in_flight;
#endif
}
@@ -680,14 +700,16 @@
// if we're not an inflight transaction - bail
if (state_ != e_in_flight)
{
- if (hasLock()) unlock_tx();
+ //if (hasLock()) unlock_tx();
return;
}
- if (!hasLock()) lock_tx();
- abort();
- unlock_tx();
- transactions().pop();
+ //if (!hasLock())
+ {
+ synchro::lock_guard<Mutex> lock(*mutex());
+ abort();
+ }
+ transactions().pop();
}
@@ -739,20 +761,14 @@
{
if (direct_updating())
{
- //bool wasWriting = isWriting() ? true : false;
- bool wasWriting = isWriting();
-
- if (wasWriting) lock(general_lock());
- lock_tx();
+ synchro::lock_guard_if<Mutex> lock_g(*general_lock(), isWriting());
+ synchro::lock_guard<Mutex> lock_m(*mutex());
direct_abort();
- unlock_tx();
- if (wasWriting) unlock(general_lock());
}
else
{
- lock_tx();
+ synchro::lock_guard<Mutex> lock_m(*mutex());
deferred_abort();
- unlock_tx();
}
}
@@ -772,8 +788,10 @@
("aborting committing transaction due to contention manager priority inversion");
}
- lock(general_lock());
- lock_tx();
+ synchro::lock(*general_lock());
+ //lock_tx();
+ synchro::lock(*mutex());
+
//--------------------------------------------------------------------------
// erase this from the inflight transactions so processing through the
@@ -789,28 +807,30 @@
// so unlock it so we can reduce contention
//-----------------------------------------------------------------------
bool wasWriting = isWriting() ? true : false;
- if (!wasWriting) unlock(general_lock());
+ if (!wasWriting) synchro::unlock(*general_lock());
direct_abort();
- unlock_tx();
+ //unlock_tx();
+ synchro::unlock(*mutex());
+
//-----------------------------------------------------------------------
// if this tx was writing, unlock the transaction mutex now
//-----------------------------------------------------------------------
- if (wasWriting) unlock(general_lock());
+ if (wasWriting) synchro::unlock(*general_lock());
throw aborted_transaction_exception
("aborting committing transaction due to contention manager priority inversion");
}
lock_all_mutexes_but_this(threadId_);
- lock(inflight_lock());
+ synchro::lock(*inflight_lock());
transactionsInFlight_.erase(this);
if (other_in_flight_same_thread_transactions())
{
state_ = e_hand_off;
unlock_all_mutexes();
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
bookkeeping_.inc_handoffs();
}
else
@@ -821,8 +841,8 @@
if (e_committed == state_)
{
unlock_all_mutexes();
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
}
}
}
@@ -854,14 +874,14 @@
if (is_only_reading())
{
//std::cout << __LINE__ << " invalidating_deferred_end_transaction" << std::endl;
- lock(inflight_lock());
+ synchro::lock(*inflight_lock());
transactionsInFlight_.erase(this);
#if PERFORMING_COMPOSITION
if (other_in_flight_same_thread_transactions())
{
//std::cout << __LINE__ << " invalidating_deferred_end_transaction" << std::endl;
- unlock(inflight_lock());
+ synchro::unlock(*inflight_lock());
state_ = e_hand_off;
bookkeeping_.inc_handoffs();
}
@@ -869,7 +889,7 @@
#endif
{
//std::cout << __LINE__ << " invalidating_deferred_end_transaction" << std::endl;
- unlock(inflight_lock());
+ synchro::unlock(*inflight_lock());
tx_type(eNormalTx);
#if PERFORMING_LATM
get_tx_conflicting_locks().clear();
@@ -884,7 +904,7 @@
return;
}
- while (0 != trylock(&transactionMutex_)) {
+ while (0 != synchro::try_lock(transactionMutex_)) {
//std::cout << __LINE__ << " invalidating_deferred_end_transaction" << std::endl;
}
@@ -898,7 +918,7 @@
//std::cout << __LINE__ << " invalidating_deferred_end_transaction" << std::endl;
if (forced_to_abort())
{
- unlock(general_lock());
+ synchro::unlock(*general_lock());
deferred_abort(true);
throw aborted_transaction_exception
("aborting committing transaction due to contention manager priority inversion");
@@ -920,7 +940,7 @@
//-----------------------------------------------------------------------
//std::cout << __LINE__ << " invalidating_deferred_end_transaction" << std::endl;
lock_all_mutexes();
- lock(inflight_lock());
+ synchro::lock(*inflight_lock());
#if PERFORMING_COMPOSITION
if (other_in_flight_same_thread_transactions())
@@ -929,8 +949,8 @@
transactionsInFlight_.erase(this);
state_ = e_hand_off;
unlock_all_mutexes();
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
bookkeeping_.inc_handoffs();
}
else
@@ -953,8 +973,8 @@
//-----------------------------------------------------------------------------
inline void transaction::validating_direct_end_transaction()
{
- lock(general_lock());
- lock_tx();
+ synchro::lock(*general_lock());
+ synchro::lock(*mutex());
//--------------------------------------------------------------------------
// can only be called after above transactionMutex_ is called
@@ -963,8 +983,8 @@
{
abort();
//bookkeeping_.inc_abort_perm_denied(threadId_);
- unlock_tx();
- unlock(general_lock());
+ synchro::unlock(*mutex());
+ synchro::unlock(*general_lock());
throw aborted_transaction_exception
("aborting commit due to CM priority");
}
@@ -983,28 +1003,28 @@
// so unlock it so we can reduce contention
//-----------------------------------------------------------------------
bool wasWriting = isWriting() ? true : false;
- if (!wasWriting) unlock(general_lock());
+ if (!wasWriting) synchro::unlock(*general_lock());
direct_abort();
- unlock_tx();
+ synchro::unlock(*general_lock());
//-----------------------------------------------------------------------
// if this tx was writing, unlock the transaction mutex now
//-----------------------------------------------------------------------
- if (wasWriting) unlock(general_lock());
+ if (wasWriting) synchro::unlock(*general_lock());
throw aborted_transaction_exception
("aborting committing transaction due to contention manager priority inversion");
}
lock_all_mutexes_but_this(threadId_);
- lock(inflight_lock());
+ synchro::lock(*inflight_lock());
transactionsInFlight_.erase(this);
if (other_in_flight_same_thread_transactions())
{
state_ = e_hand_off;
unlock_all_mutexes();
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
bookkeeping_.inc_handoffs();
}
else
@@ -1015,8 +1035,8 @@
if (e_committed == state_)
{
unlock_all_mutexes();
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
}
}
}
@@ -1026,9 +1046,9 @@
//-----------------------------------------------------------------------------
inline void transaction::validating_deferred_end_transaction()
{
- lock(general_lock());
- lock(inflight_lock());
- lock_tx();
+ synchro::lock(*general_lock());
+ synchro::lock(*inflight_lock());
+ synchro::lock(*mutex());
//--------------------------------------------------------------------------
// can only be called after above transactionMutex_ is called
@@ -1036,16 +1056,16 @@
if (cm_abort_before_commit(*this))
{
//bookkeeping_.inc_abort_perm_denied(threadId_);
- unlock(inflight_lock());
- unlock(general_lock());
- deferred_abort();
- unlock_tx();
+ synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock());
+ //unlock_tx();
+ synchro::unlock(*mutex());
throw aborted_transaction_exception
("aborting commit due to CM priority");
}
// unlock this - we only needed it to check abort_before_commit()
- unlock(inflight_lock());
+ synchro::unlock(*inflight_lock());
uint32 ms = clock();
@@ -1058,9 +1078,9 @@
//--------------------------------------------------------------------------
if (forced_to_abort())
{
- unlock(general_lock());
+ synchro::unlock(*general_lock());
deferred_abort();
- unlock_tx();
+ synchro::unlock(*mutex());
throw aborted_transaction_exception
("aborting committing transaction due to contention manager priority inversion");
}
@@ -1074,7 +1094,7 @@
//--------------------------------------------------------------------------
if (is_only_reading())
{
- lock(inflight_lock());
+ synchro::lock(*inflight_lock());
transactionsInFlight_.erase(this);
if (other_in_flight_same_thread_transactions())
@@ -1092,15 +1112,15 @@
state_ = e_committed;
}
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
bookkeeping_.inc_commits();
#ifndef DISABLE_READ_SETS
bookkeeping_.pushBackSizeOfReadSetWhenCommitting(readList().size());
#endif
bookkeeping_.inc_commit_time_ms(clock() - ms);
- unlock_tx();
+ synchro::unlock(*mutex());
}
//-----------------------------------------------------------------------
@@ -1118,15 +1138,15 @@
//-----------------------------------------------------------------------
lock_all_mutexes_but_this(threadId_);
- lock(inflight_lock());
+ synchro::lock(*inflight_lock());
transactionsInFlight_.erase(this);
if (other_in_flight_same_thread_transactions())
{
state_ = e_hand_off;
unlock_all_mutexes();
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
bookkeeping_.inc_handoffs();
}
else
@@ -1139,9 +1159,10 @@
// unlocked these already
if (e_committed == state_)
{
- unlock_tx();
- unlock(general_lock());
- unlock(inflight_lock());
+ //unlock_tx();
+ synchro::unlock(*mutex());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
}
}
}
@@ -1260,7 +1281,7 @@
#endif
if (!alreadyRemovedFromInFlight)
{
- lock(inflight_lock());
+ synchro::lock(*inflight_lock());
// if I'm the last transaction of this thread, reset abort to false
transactionsInFlight_.erase(this);
}
@@ -1275,7 +1296,7 @@
#endif
if (!alreadyRemovedFromInFlight)
{
- unlock(inflight_lock());
+ synchro::unlock(*inflight_lock());
}
}
catch (...)
@@ -1310,7 +1331,7 @@
if (alreadyRemovedFromInFlight)
{
- lock(inflight_lock());
+ synchro::lock(*inflight_lock());
// if I'm the last transaction of this thread, reset abort to false
transactionsInFlight_.erase(this);
@@ -1323,7 +1344,7 @@
unforce_to_abort();
#endif
- unlock(inflight_lock());
+ synchro::unlock(*inflight_lock());
}
else unforce_to_abort();
}
@@ -1371,11 +1392,11 @@
catch (aborted_transaction_exception&)
{
unlock_all_mutexes_but_this(threadId_);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
direct_abort();
- unlock_tx();
+ synchro::unlock(*mutex());
throw;
}
@@ -1385,11 +1406,11 @@
catch (...)
{
unlock_all_mutexes_but_this(threadId_);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
direct_abort();
- unlock_tx();
+ synchro::unlock(*mutex());
throw;
}
@@ -1447,8 +1468,8 @@
++stalling_;
size_t local_clock = global_clock();
- unlock(inflight_lock());
- unlock(general_lock());
+ synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock());
unlock_all_mutexes();
for (;;)
@@ -1465,8 +1486,8 @@
throw aborted_transaction_exception_no_unlocks();
}
- lock(general_lock());
- lock(inflight_lock());
+ synchro::lock(*general_lock());
+ synchro::lock(*inflight_lock());
// if our stalling on tx is gone, continue
if (transactionsInFlight_.end() == transactionsInFlight_.find(stallingOn))
@@ -1478,8 +1499,8 @@
break;
}
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
}
lock_all_mutexes();
@@ -1499,8 +1520,8 @@
}
transactionsInFlight_.erase(this);
- unlock(inflight_lock());
- unlock(general_lock());
+ synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock());
deferredCommitWriteState();
@@ -1547,10 +1568,10 @@
catch (aborted_transaction_exception&)
{
unlock_all_mutexes_but_this(threadId_);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
deferred_abort();
- unlock_tx();
+ synchro::unlock(*mutex());
throw;
}
@@ -1560,10 +1581,10 @@
catch (...)
{
unlock_all_mutexes_but_this(threadId_);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
deferred_abort();
- unlock_tx();
+ synchro::unlock(*mutex());
throw;
}
@@ -1632,11 +1653,11 @@
catch (aborted_transaction_exception&)
{
unlock_all_mutexes_but_this(threadId_);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
direct_abort();
- unlock_tx();
+ synchro::unlock(*mutex());
throw;
}
@@ -1646,11 +1667,11 @@
catch (...)
{
unlock_all_mutexes_but_this(threadId_);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
direct_abort();
- unlock_tx();
+ synchro::unlock(*mutex());
throw;
}
@@ -1740,10 +1761,10 @@
catch (aborted_transaction_exception&)
{
unlock_all_mutexes_but_this(threadId_);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
deferred_abort();
- unlock_tx();
+ synchro::unlock(*mutex());
throw;
}
@@ -1753,10 +1774,10 @@
catch (...)
{
unlock_all_mutexes_but_this(threadId_);
- unlock(general_lock());
- unlock(inflight_lock());
+ synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock());
deferred_abort();
- unlock_tx();
+ synchro::unlock(*mutex());
throw;
}
Modified: sandbox/stm/branches/vbe/boost/stm/memory_managers/base_memory_manager.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/memory_managers/base_memory_manager.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/memory_managers/base_memory_manager.hpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -50,28 +50,15 @@
static void return_mem(void *mem, size_t size)
{
-#ifndef BOOST_STM_USE_BOOST_MUTEX
- lock(&transactionObjectMutex_);
+ synchro::lock_guard<Mutex> lock(transactionObjectMutex_);
memory_.returnChunk(mem, size);
- unlock(&transactionObjectMutex_);
-#else
- boost::lock_guard<boost::mutex> lock(transactionObjectMutex_);
- memory_.returnChunk(mem, size);
-#endif
}
static void* retrieve_mem(size_t size)
{
-#ifndef BOOST_STM_USE_BOOST_MUTEX
- lock(&transactionObjectMutex_);
- void *mem = memory_.retrieveChunk(size);
- unlock(&transactionObjectMutex_);
-#else
- boost::lock_guard<boost::mutex> lock(transactionObjectMutex_);
+ synchro::lock_guard<Mutex> lock(transactionObjectMutex_);
void *mem = memory_.retrieveChunk(size);
-#endif
-
- return mem;
+ return mem;
}
private:
Modified: sandbox/stm/branches/vbe/boost/stm/synchro.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synchro.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synchro.hpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -14,20 +14,27 @@
#ifndef BOOST_STM_SYNCHO__HPP
#define BOOST_STM_SYNCHO__HPP
+#include <boost/stm/detail/config.hpp>
+
//-----------------------------------------------------------------------------
#include <stdarg.h>
#include <pthread.h>
//-----------------------------------------------------------------------------
#include <list>
+#include <stdexcept>
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-#include <boost/stm/detail/config.hpp>
//-----------------------------------------------------------------------------
//#include <boost/stm/exceptions.hpp>
//-----------------------------------------------------------------------------
//#include <boost/stm/detail/memory_pool.hpp>
//-----------------------------------------------------------------------------
+#ifdef BOOST_STM_USE_BOOST
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread_time.hpp>
+#endif
+
#ifndef BOOST_STM_USE_BOOST_MUTEX
typedef pthread_mutex_t Mutex;
#else
@@ -35,107 +42,383 @@
#endif
//-----------------------------------------------------------------------------
-namespace boost { namespace stm {
+namespace boost {
+namespace synchro {
-//-----------------------------------------------------------------------------
-// forward declarations
-//-----------------------------------------------------------------------------
+ class lock_error : public std::exception
+ {
+ public:
+ lock_error() {}
+ ~lock_error() throw() {}
-#ifndef BOOST_STM_USE_BOOST_MUTEX
-typedef pthread_mutex_t PLOCK;
-#else
-typedef boost::mutex PLOCK;
+ virtual const char* what() const throw() {return "synchro::lock_error";}
+ };
+
+ struct defer_lock_t
+ {};
+ struct try_to_lock_t
+ {};
+ struct adopt_lock_t
+ {};
+
+ const defer_lock_t defer_lock={};
+ const try_to_lock_t try_to_lock={};
+ const adopt_lock_t adopt_lock={};
+
+ template< typename Lockable >
+ inline void lock(Lockable& lockable) {
+ lockable.lock();
+ }
+
+ template< typename Lockable >
+ inline void unlock(Lockable& lockable) {
+ lockable.unlock();
+ }
+
+ template< typename Lockable >
+ inline bool try_lock(Lockable& lockable) {
+ return lockable.try_lock();
+ }
+
+#ifdef BOOST_PTHREAD_HAS_TIMEDLOCK
+ template <typename Lockable, typename TimeDuration >
+ bool lock_for(Lockable& lockable, const TimeDuration& rel_time) {
+ return lock_until(&lockable, get_system_time()+rel_time);
+ }
+
+ template< typename Lockable>
+ inline bool lock_until(Lockable& lockable, system_time const& target_time) {
+ return lockable.timed_lock(target_time);
+ }
#endif
+ template<>
+ inline void lock<pthread_mutex_t>(pthread_mutex_t& lockable) {
+ pthread_mutex_lock(&lockable);
+ }
+
+ template<>
+ inline void unlock<pthread_mutex_t>(pthread_mutex_t& lockable) {
+ pthread_mutex_unlock(&lockable);
+ }
+
+ template<>
+ inline bool try_lock<pthread_mutex_t>(pthread_mutex_t& lockable) {
+ return pthread_mutex_trylock(&lockable);
+ }
+
+#ifdef BOOST_PTHREAD_HAS_TIMEDLOCK
+ template<>
+ inline bool lock_until<pthread_mutex_t>(
+ pthread_mutex_t& lockable, system_time const& abs_time) {
+ struct timespec const timeout=boost::detail::get_timespec(abs_time);
+ int const res=pthread_mutex_timedlock(&lockable,&timeout);
+ //BOOST_ASSERT(!res || res==ETIMEDOUT);
+ return !res;
+ }
+#endif
+
+ template<typename Mutex>
+ class lock_guard
+ {
+ private:
+ Mutex& m;
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-#ifndef BOOST_STM_USE_BOOST_MUTEX
+ explicit lock_guard(lock_guard&);
+ lock_guard& operator=(lock_guard&);
+ public:
+ explicit lock_guard(Mutex& m_)
+ : m(m_)
+ {
+ synchro::lock(m);
+ }
+ lock_guard(Mutex& m_,adopt_lock_t)
+ : m(m_)
+ {}
+ ~lock_guard()
+ {
+ synchro::unlock(m);
+ }
+ };
-#if 0
- template <typename T>
- inline int lock(T *lock) { throw "unsupported lock type"; }
+ template<typename Mutex>
+ class lock_guard_if
+ {
+ private:
+ Mutex& m;
+ bool cnd_;
- template <typename T>
- inline int trylock(T *lock) { throw "unsupported lock type"; }
+ explicit lock_guard_if(lock_guard_if&);
+ lock_guard_if& operator=(lock_guard_if&);
+ public:
+ explicit lock_guard_if(Mutex& m_, bool cnd)
+ : m(m_)
+ , cnd_(cnd)
+ {
+ if (cnd_) synchro::lock(m);
+ }
+ lock_guard_if(Mutex& m_, bool cnd,adopt_lock_t)
+ : m(m_)
+ , cnd_(cnd)
+ {}
+ ~lock_guard_if()
+ {
+ if (cnd_) synchro::unlock(m);
+ }
+ };
+
+
+ template<typename Mutex>
+ class unique_lock
+ {
+ private:
+ Mutex* m;
+ bool is_locked;
+ unique_lock(unique_lock&);
+ unique_lock& operator=(unique_lock&);
+ public:
+ unique_lock():
+ m(0),is_locked(false)
+ {}
+
+ explicit unique_lock(Mutex& m_):
+ m(&m_),is_locked(false)
+ {
+ lock();
+ }
+
+ unique_lock(Mutex& m_,adopt_lock_t):
+ m(&m_),is_locked(true)
+ {}
+ unique_lock(Mutex& m_,defer_lock_t):
+ m(&m_),is_locked(false)
+ {}
+ unique_lock(Mutex& m_,try_to_lock_t):
+ m(&m_),is_locked(false)
+ {
+ try_lock();
+ }
+#ifdef BOOST_PTHREAD_HAS_TIMEDLOCK
+ template<typename TimeDuration>
+ unique_lock(Mutex& m_,TimeDuration const& target_time):
+ m(&m_),is_locked(false)
+ {
+ timed_lock(target_time);
+ }
+ unique_lock(Mutex& m_,boost::system_time const& target_time):
+ m(&m_),is_locked(false)
+ {
+ timed_lock(target_time);
+ }
+#endif
+#if 0
+#ifdef BOOST_HAS_RVALUE_REFS
+ unique_lock(unique_lock&& other):
+ m(other.m),is_locked(other.is_locked)
+ {
+ other.is_locked=false;
+ other.m=0;
+ }
+ unique_lock<Mutex>&& move()
+ {
+ return static_cast<unique_lock<Mutex>&&>(*this);
+ }
- template <typename T>
- inline int unlock(T *lock) { throw "unsupported lock type"; }
- template <>
- inline int lock(Mutex &lock) { return pthread_mutex_lock(&lock); }
+ unique_lock& operator=(unique_lock<Mutex>&& other)
+ {
+ unique_lock temp(other);
+ swap(temp);
+ return *this;
+ }
- template <>
- inline int lock(Mutex *lock) { return pthread_mutex_lock(lock); }
+ void swap(unique_lock&& other)
+ {
+ std::swap(m,other.m);
+ std::swap(is_locked,other.is_locked);
+ }
+#else
+ unique_lock(detail::thread_move_t<unique_lock<Mutex> > other):
+ m(other->m),is_locked(other->is_locked)
+ {
+ other->is_locked=false;
+ other->m=0;
+ }
- template <>
- inline int trylock(Mutex &lock) { return pthread_mutex_trylock(&lock); }
+ operator detail::thread_move_t<unique_lock<Mutex> >()
+ {
+ return move();
+ }
- template <>
- inline int trylock(Mutex *lock) { return pthread_mutex_trylock(lock); }
+ detail::thread_move_t<unique_lock<Mutex> > move()
+ {
+ return detail::thread_move_t<unique_lock<Mutex> >(*this);
+ }
- template <>
- inline int unlock(Mutex &lock) { return pthread_mutex_unlock(&lock); }
+ unique_lock& operator=(detail::thread_move_t<unique_lock<Mutex> > other)
+ {
+ unique_lock temp(other);
+ swap(temp);
+ return *this;
+ }
- template <>
- inline int unlock(Mutex *lock) { return pthread_unlock(lock); }
+ void swap(unique_lock& other)
+ {
+ std::swap(m,other.m);
+ std::swap(is_locked,other.is_locked);
+ }
+ void swap(detail::thread_move_t<unique_lock<Mutex> > other)
+ {
+ std::swap(m,other->m);
+ std::swap(is_locked,other->is_locked);
+ }
+#endif
#else
- inline int lock(PLOCK &lock) { return pthread_mutex_lock(&lock); }
- inline int lock(PLOCK *lock) { return pthread_mutex_lock(lock); }
+ void swap(unique_lock& other)
+ {
+ std::swap(m,other.m);
+ std::swap(is_locked,other.is_locked);
+ }
+
+#endif
+ ~unique_lock()
+ {
+ if(owns_lock())
+ {
+ synchro::unlock(*m);
+ }
+ }
+ void lock()
+ {
+ if(owns_lock())
+ {
+ throw lock_error();
+ }
+ synchro::lock(*m);
+ is_locked=true;
+ }
+ bool try_lock()
+ {
+ if(owns_lock())
+ {
+ throw lock_error();
+ }
+ is_locked=synchro::try_lock(*m);
+ return is_locked;
+ }
+#ifdef BOOST_PTHREAD_HAS_TIMEDLOCK
+ template<typename TimeDuration>
+ bool timed_lock(TimeDuration const& relative_time)
+ {
+ is_locked=synchro::timed_lock(*m, relative_time);
+ return is_locked;
+ }
+
+ bool timed_lock(::boost::system_time const& absolute_time)
+ {
+ is_locked=synchro::timed_lock(*m, absolute_time);
+ return is_locked;
+ }
+ bool timed_lock(::boost::xtime const& absolute_time)
+ {
+ is_locked=synchro::timed_lock(*m, absolute_time);
+ return is_locked;
+ }
+#endif
+ void unlock()
+ {
+ if(!owns_lock())
+ {
+ throw lock_error();
+ }
+ synchro::unlock(*m);
+ 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;
+ }
- inline int trylock(PLOCK &lock) { return pthread_mutex_trylock(&lock); }
- inline int trylock(PLOCK *lock) { return pthread_mutex_trylock(lock); }
+ Mutex* release()
+ {
+ Mutex* const res=m;
+ m=0;
+ is_locked=false;
+ return res;
+ }
+ };
- inline int unlock(PLOCK &lock) { return pthread_mutex_unlock(&lock); }
- inline int unlock(PLOCK *lock) { return pthread_mutex_unlock(lock); }
+#if 0
+#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
#else
- inline void lock(PLOCK &lock) { lock.lock(); }
- inline void lock(PLOCK *lock) { lock->lock(); }
-
- inline bool trylock(PLOCK &lock) { return lock.try_lock(); }
- inline bool trylock(PLOCK *lock) { return lock->try_lock(); }
+ template<typename Mutex>
+ void swap(unique_lock<Mutex>& lhs,unique_lock<Mutex>& rhs)
+ {
+ lhs.swap(rhs);
+ }
+#endif
- inline void unlock(PLOCK &lock) { lock.unlock(); }
- inline void unlock(PLOCK *lock) { lock->unlock(); }
+#if 0
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename Mutex>
+ inline unique_lock<Mutex>&& move(unique_lock<Mutex>&& ul)
+ {
+ return ul;
+ }
+#endif
#endif
+
+}
+namespace stm {
//-----------------------------------------------------------------------------
+// forward declarations
//-----------------------------------------------------------------------------
- template<typename Lockable>
- class lock_guard2
- {
- private:
- Lockable& m;
- //bool owns_;
- explicit lock_guard2(lock_guard2&);
- lock_guard2& operator=(lock_guard2&);
- public:
- inline explicit lock_guard2(Lockable& m_):
- m(m_)
- {
- lock();
- }
- inline ~lock_guard2()
- {
- //unlock();
- }
- //inline bool owns_lock() { return owns_;}
- inline void lock() {
- //if (owns_)
- stm::lock(m);
- //owns_=true;
- }
- inline void unlock() {
- //if (owns_)
- stm::unlock(m);
- //owns_=false;
- }
- //inline void release() {
- // owns_=false;
- //}
- };
+typedef pthread_mutex_t PLOCK;
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+ inline int lock22(PLOCK &lock) { return pthread_mutex_lock(&lock); }
+ inline int lock22(PLOCK *lock) { return pthread_mutex_lock(lock); }
+
+ inline int trylock22(PLOCK &lock) { return pthread_mutex_trylock(&lock); }
+ inline int trylock22(PLOCK *lock) { return pthread_mutex_trylock(lock); }
+
+ inline int unlock22(PLOCK &lock) { return pthread_mutex_unlock(&lock); }
+ inline int unlock22(PLOCK *lock) { return pthread_mutex_unlock(lock); }
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@@ -165,7 +448,7 @@
void do_auto_lock(Mutex *mutex)
{
lock_ = mutex;
- pthread_mutex_lock(mutex);
+ synchro::lock(*mutex);
hasLock_ = true;
}
@@ -174,7 +457,7 @@
if (hasLock_)
{
hasLock_ = false;
- pthread_mutex_unlock(lock_);
+ synchro::unlock(*lock_);
}
}
@@ -212,7 +495,7 @@
for (; i != lockList_.end(); ++i)
{
- lock(*i);
+ synchro::lock(**i);
}
}
@@ -221,7 +504,7 @@
{
for (std::list<PLOCK*>::iterator i = lockList_.begin(); i != lockList_.end(); ++i)
{
- unlock(*i);
+ synchro::unlock(**i);
}
}
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-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -538,13 +538,14 @@
// an exception here because restarting the transactions will cause it to
// infinitely fail
//-----------------------------------------------------------------------
- lock(inflight_lock());
+ synchro::lock_guard<Mutex> lock_m(*inflight_lock());
+ //lock(inflight_lock());
if (other_in_flight_same_thread_transactions())
{
- unlock(inflight_lock());
+ //unlock(inflight_lock());
throw aborted_transaction_exception("closed nesting throw");
}
- unlock(inflight_lock());
+ //unlock(inflight_lock());
return true;
}
@@ -866,7 +867,7 @@
static std::string outputBlockedThreadsAndLockedLocks();
#endif
//--------------------------------------------------------------------------
- inline int const& hasLock() const { return hasMutex_; }
+ //inline int const& hasLock() const { return hasMutex_; }
void lock_tx();
void unlock_tx();
@@ -922,14 +923,17 @@
// if transaction_thread() is not invalid (and not us), we get original
// object from the thread that is changing it
//--------------------------------------------------------------------
- lock(&transactionMutex_);
- lock_tx();
+ //lock(&transactionMutex_);
+ synchro::lock_guard<Mutex> guard_transactionMutex(transactionMutex_);
+ //lock_tx();
+ synchro::lock_guard<Mutex> lock(*mutex());
+
if (in.transaction_thread() != kInvalidThread)
{
- //lock_guard2<Mutex> guard(mutex(in.transaction_thread()));
- Mutex& m=mutex(in.transaction_thread());
- stm::lock(m);
+ synchro::lock_guard<Mutex> guard(mutex(in.transaction_thread()));
+ //Mutex& m=mutex(in.transaction_thread());
+ //stm::lock(m);
WriteContainer* c = write_lists(in.transaction_thread());
WriteContainer::iterator readMem = c->find((base_transaction_object*)&in);
@@ -944,10 +948,7 @@
#if USE_BLOOM_FILTER
bloom().insert((size_t)readMem->second);
#endif
- unlock(&transactionMutex_);
- unlock_tx();
- stm::unlock(m);
- //guard.unlock();
+ //unlock_tx();
++reads_;
return *static_cast<T*>(readMem->second);
@@ -960,8 +961,7 @@
#if USE_BLOOM_FILTER
bloom().insert((size_t)&in);
#endif
- unlock(&transactionMutex_);
- unlock_tx();
+ //unlock_tx();
++reads_;
return in;
}
@@ -977,7 +977,8 @@
cm_abort_on_write(*this, (base_transaction_object&)(in));
}
- lock_tx();
+ synchro::lock_guard<Mutex> lock(*mutex());
+ //lock_tx();
// already have locked us above - in both if / else
#ifndef DISABLE_READ_SETS
readList().insert((base_transaction_object*)&in);
@@ -985,7 +986,7 @@
#if USE_BLOOM_FILTER
bloom().insert((size_t)&in);
#endif
- unlock_tx();
+ //unlock_tx();
++reads_;
}
return in;
@@ -1009,13 +1010,14 @@
// memory - since we need to ensure other threads don't try to
// manipulate this at the same time we are going to
//-----------------------------------------------------------------------
- lock(&transactionMutex_);
+ //lock(&transactionMutex_);
+ synchro::lock_guard<Mutex> lock_m(transactionMutex_);
// we currently don't allow write stealing in direct update. if another
// tx beat us to the memory, we abort
if (in.transaction_thread() != kInvalidThread)
{
- unlock(&transactionMutex_);
+ //unlock(&transactionMutex_);
throw aborted_tx("direct writer already exists.");
}
@@ -1024,7 +1026,7 @@
#if USE_BLOOM_FILTER
bloom().insert((size_t)&in);
#endif
- unlock(&transactionMutex_);
+ //unlock(&transactionMutex_);
return in;
}
@@ -1043,17 +1045,20 @@
// and see if anyone else is writing to it. if not, we add the item to
// our write list and our deletedList
//-----------------------------------------------------------------------
- lock(&transactionMutex_);
+ //lock(&transactionMutex_);
+ synchro::unique_lock<Mutex> lock_m(transactionMutex_);
if (in.transaction_thread() != kInvalidThread)
{
- unlock(&transactionMutex_);
+ //unlock(&transactionMutex_);
cm_abort_on_write(*this, (base_transaction_object&)(in));
}
else
{
in.transaction_thread(threadId_);
- unlock(&transactionMutex_);
+
+ //unlock(&transactionMutex_);
+ lock_m.unlock();
// is this really necessary? in the deferred case it is, but in direct it
// doesn't actually save any time for anything
//writeList()[(base_transaction_object*)&in] = 0;
@@ -1077,17 +1082,19 @@
// and see if anyone else is writing to it. if not, we add the item to
// our write list and our deletedList
//-----------------------------------------------------------------------
- lock(&transactionMutex_);
+ //lock(&transactionMutex_);
+ synchro::unique_lock<Mutex> lock_m(transactionMutex_);
if (in.transaction_thread() != kInvalidThread)
{
- unlock(&transactionMutex_);
+ //unlock(&transactionMutex_);
cm_abort_on_write(*this, (base_transaction_object&)(in));
}
else
{
in.transaction_thread(threadId_);
- unlock(&transactionMutex_);
+ //unlock(&transactionMutex_);
+ lock_m.unlock();
// is this really necessary? in the deferred case it is, but in direct it
// doesn't actually save any time for anything
//writeList()[(base_transaction_object*)&in] = 0;
@@ -1147,7 +1154,8 @@
#else
if (bloom().exists((size_t)&in)) return in;
#endif
- lock_tx();
+ synchro::lock_guard<Mutex> lock(*mutex());
+ //lock_tx();
#ifndef DISABLE_READ_SETS
#if PERFORMING_VALIDATION
readList()[(base_transaction_object*)&in] = in.version_;
@@ -1158,7 +1166,7 @@
#if USE_BLOOM_FILTER
bloom().insert((size_t)&in);
#endif
- unlock_tx();
+ //unlock_tx();
++reads_;
return in;
}
@@ -1186,10 +1194,14 @@
if (i == writeList().end())
{
// get the lock before we make a copy of this object
- lock_tx();
+ //lock_tx();
+ synchro::unique_lock<Mutex> lock(*mutex());
#if USE_BLOOM_FILTER
bloom().insert((size_t)&in);
- unlock_tx();
+ //unlock_tx();
+ lock.unlock();
+#else
+
#endif
#if PERFORMING_WRITE_BLOOM
wbloom().set_bv1(bloom().h1());
@@ -1200,7 +1212,7 @@
returnValue->transaction_thread(threadId_);
writeList().insert(tx_pair((base_transaction_object*)&in, returnValue));
#ifndef USE_BLOOM_FILTER
- unlock_tx();
+ //unlock_tx();
#endif
return *static_cast<T*>(returnValue);
}
@@ -1224,9 +1236,11 @@
//-----------------------------------------------------------------------
if (in.transaction_thread() != kInvalidThread)
{
- lock_tx();
+ { synchro::lock_guard<Mutex> lock(*mutex());
+ //lock_tx();
bloom().insert((size_t)&in);
- unlock_tx();
+ //unlock_tx();
+ }
writeList().insert(tx_pair((base_transaction_object*)&in, 0));
}
//-----------------------------------------------------------------------
@@ -1236,9 +1250,11 @@
//-----------------------------------------------------------------------
else
{
- lock_tx();
+ { synchro::lock_guard<Mutex> lock(*mutex());
+ //lock_tx();
bloom().insert((size_t)&in);
- unlock_tx();
+ //unlock_tx();
+ }
// check the ENTIRE write container for this piece of memory in the
// second location. If it's there, it means we made a copy of a piece
for (WriteContainer::iterator j = writeList().begin(); writeList().end() != j; ++j)
@@ -1997,7 +2013,7 @@
// transaction specific data
- int hasMutex_; // bool - 1 bit
+ //int hasMutex_; // bool - 1 bit
mutable size_t priority_;
transaction_state state_; // 2bits
size_t reads_;
@@ -2020,14 +2036,14 @@
template <typename MUTEX, MUTEX& mtx>
locker<MUTEX,mtx>::locker() {
- boost::stm::lock(mtx);
+ synchro::lock(mtx);
}
template <typename MUTEX, MUTEX& mtx>
locker<MUTEX,mtx>::~locker() {}
template <typename MUTEX, MUTEX& mtx>
void locker<MUTEX,mtx>::unlock() {
- boost::stm::unlock(mtx);
+ synchro::unlock(mtx);
}
template <class T> T* cache_allocate(transaction* t) {
Modified: sandbox/stm/branches/vbe/libs/stm/build/Jamfile.v2
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/build/Jamfile.v2 (original)
+++ sandbox/stm/branches/vbe/libs/stm/build/Jamfile.v2 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -47,6 +47,7 @@
# <define>BOOST_THREAD_HAS_THREAD_ATTR
<include>../../..
+ #<include>$BOOST_ROOT
<include>/boost_1_39_0
<link>static:<define>BOOST_INTERTHREADS_BUILD_LIB=1
<link>shared:<define>BOOST_INTERTHREADS_BUILD_DLL=1
Modified: sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -160,7 +160,7 @@
///////////////////////////////////////////////////////////////////////////////
void transaction::initialize_thread()
{
- lock(general_lock());
+ synchro::lock_guard<Mutex> lock(*general_lock());
//--------------------------------------------------------------------------
// WARNING: before you think lock_all_mutexes() does not make sense, make
@@ -421,14 +421,16 @@
//--------------------------------------------------------------------------
- unlock(general_lock());
+ //synchro::unlock(*general_lock());
}
///////////////////////////////////////////////////////////////////////////////
void transaction::terminate_thread()
{
- lock(general_lock());
- lock(inflight_lock());
+ synchro::lock_guard<Mutex> lock_g(*general_lock());
+ //synchro::lock(*general_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ //synchro::lock(*inflight_lock());
size_t threadId = THREAD_ID;
@@ -527,8 +529,8 @@
#endif
- unlock(inflight_lock());
- unlock(general_lock());
+ //synchro::unlock(*inflight_lock());
+ //synchro::unlock(*general_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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -22,7 +22,8 @@
<include>.
<include>../../..
- <include>$BOOST_ROOT
+ #<include>$BOOST_ROOT
+ <include>/boost_1_39_0
<threading>multi
# <target-os>cygwin
# <interthreadapi>pthread
Modified: sandbox/stm/branches/vbe/libs/stm/test/globalIntArr.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/globalIntArr.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/globalIntArr.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -29,8 +29,8 @@
using namespace nGlobalIntArr;
int globalCountExe = 0;
-boost::stm::native_trans<int> global_int;
-boost::stm::native_trans<int> arr[kMaxGlobalIntSize];
+native_trans<int> global_int;
+native_trans<int> arr[kMaxGlobalIntSize];
int executionsPending = 0;
Modified: sandbox/stm/branches/vbe/libs/stm/test/irrevocableInt.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/irrevocableInt.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/irrevocableInt.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -44,7 +44,7 @@
////////////////////////////////////////////////////////////////////////////
using namespace std; using namespace boost::stm;
-static boost::stm::native_trans<int> globalInt;
+static native_trans<int> globalInt;
///////////////////////////////////////////////////////////////////////////////
static void* TestIsolatedComposedLockInTxCount(void *threadId)
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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -102,7 +102,8 @@
}
///////////////////////////////////////////////////////////////////////////////
-void* Test2(void *threadId)
+#if 0
+static void* Test2(void *threadId)
{
transaction::initialize_thread();
int start = *(int*)threadId;
@@ -139,7 +140,7 @@
return 0;
}
-
+#endif
///////////////////////////////////////////////////////////////////////////////
static void* Test3(void *threadId)
{
Modified: sandbox/stm/branches/vbe/libs/stm/test/isolatedInt.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/isolatedInt.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/isolatedInt.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -45,7 +45,7 @@
////////////////////////////////////////////////////////////////////////////
using namespace std; using namespace boost::stm;
-static boost::stm::native_trans<int> globalInt;
+static native_trans<int> globalInt;
///////////////////////////////////////////////////////////////////////////////
static void* TestIsolatedLockInTxCount(void *threadId)
@@ -118,7 +118,8 @@
}
///////////////////////////////////////////////////////////////////////////////
-void* TestCount2(void *threadId)
+#if 0
+static void* TestCount(void *threadId)
{
transaction::initialize_thread();
int start = *(int*)threadId;
@@ -162,7 +163,7 @@
return 0;
}
-
+#endif
///////////////////////////////////////////////////////////////////////////////
void TestIsolatedIntLockInTx()
{
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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -39,19 +39,19 @@
static Mutex L2 = PTHREAD_MUTEX_INITIALIZER;
static Mutex L3 = PTHREAD_MUTEX_INITIALIZER;
static Mutex L4 = PTHREAD_MUTEX_INITIALIZER;
-static Mutex L8 = PTHREAD_MUTEX_INITIALIZER;
+//static Mutex L8 = PTHREAD_MUTEX_INITIALIZER;
#else
static Mutex L2;
static Mutex L3;
static Mutex L4;
-static Mutex L8;
+//static Mutex L8;
#endif
////////////////////////////////////////////////////////////////////////////
using namespace std; using namespace boost::stm;
static native_trans<int> *arr1, *arr2, *arr3, *arr4, *arr5, *arr6, *arr7, *arr8;
-static bool work1 = false, work2 = false, work3 = false;
+static bool work1 = false, work2 = false; //,work3 = false;
static int txFactor = 1;
static int lockFactor = 1;
@@ -133,7 +133,8 @@
}
}
-void do_work3()
+#if 0
+static void do_work3()
{
if (work3) return;
work3 = true;
@@ -145,7 +146,7 @@
}
transaction::unlock_(L8);
}
-
+#endif
static void* tx1(void *threadId)
{
transaction::initialize_thread();
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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -40,23 +40,23 @@
static Mutex L1 = PTHREAD_MUTEX_INITIALIZER;
static Mutex L2 = PTHREAD_MUTEX_INITIALIZER;
static Mutex L3 = PTHREAD_MUTEX_INITIALIZER;
-static Mutex L8 = PTHREAD_MUTEX_INITIALIZER;
-static Mutex L9 = PTHREAD_MUTEX_INITIALIZER;
+//static Mutex L8 = PTHREAD_MUTEX_INITIALIZER;
+//static Mutex L9 = PTHREAD_MUTEX_INITIALIZER;
#else
static Mutex L1;
static Mutex L2;
static Mutex L3;
-static Mutex L8;
-static Mutex L9;
+//static Mutex L8;
+//static Mutex L9;
#endif
////////////////////////////////////////////////////////////////////////////
using namespace std; using namespace boost::stm;
-static native_trans<int> *arr1, *arr2, *arr3, *arr4, *arr5, *arr6, *arr7, *arr8, *arr9;
+static native_trans<int> *arr1, *arr2, *arr3, *arr4, *arr5, *arr6, *arr7, *arr8; //, *arr9;
-static bool work1 = false, work2 = false, work3 = false, work4 = false;
+static bool work1 = false, work2 = false; //, work3 = false, work4 = false;
static int txFactor = 1;
static int lockFactor = 1;
@@ -105,7 +105,8 @@
}
}
-void do_work3bis()
+#if 0
+static void do_work3()
{
if (work3) return;
work3 = true;
@@ -120,8 +121,9 @@
transaction::unlock_(L8);
}
}
-
-void do_work4()
+#endif
+#if 0
+static void do_work4()
{
if (work4) return;
work4 = true;
@@ -136,7 +138,7 @@
transaction::unlock_(L9);
}
}
-
+#endif
static void* tx1(void *threadId)
{
transaction::initialize_thread();
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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -52,10 +52,11 @@
static native_trans<int> x = 0;
static native_trans<int> y = 0;
+#if 0
static void tx_bar();
static void lk_bar();
-void* tx_foo(void*)
+static void* tx_foo(void*)
{
transaction::initialize_thread();
size_t tries = 0;
@@ -80,10 +81,9 @@
t.write(y) = t.read(x) + y;
}
}
-
-
-
-void* lk_foo(void*)
+#endif
+#if 0
+static void* lk_foo(void*)
{
use_lock(&L)
{
@@ -93,7 +93,8 @@
return 0;
}
-
+#endif
+#if 0
static void lk_bar()
{
use_lock(L)
@@ -102,13 +103,12 @@
cout << "locking done" << endl;
}
}
-
+#endif
////////////////////////////////////////////////////////////////////////////
-using namespace std; using namespace boost::stm;
using namespace nMain;
@@ -179,7 +179,6 @@
///////////////////////////////////////////////////////////////////////////////
static void TestTransactionInsideLock()
{
- using namespace boost::stm;
cout << "X: " << x.value() << endl;
@@ -208,7 +207,6 @@
///////////////////////////////////////////////////////////////////////////////
static void TestEarlyRelease()
{
- using namespace boost::stm;
cout << "X: " << x.value() << endl;
Modified: sandbox/stm/branches/vbe/libs/stm/test/pointer_test.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/pointer_test.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/pointer_test.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -71,15 +71,15 @@
static void* pointer_access_test(void*)
{
- boost::stm::transaction::initialize_thread();
+ transaction::initialize_thread();
do_pointer_access();
return 0;
}
void pointer_test()
{
- boost::stm::transaction::initialize();
- boost::stm::transaction::initialize_thread();
+ transaction::initialize();
+ transaction::initialize_thread();
pthread_t *threads = new pthread_t[kMaxThreads];
int *threadId = new int[kMaxThreads];
Modified: sandbox/stm/branches/vbe/libs/stm/test/smart.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/smart.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/smart.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -27,6 +27,7 @@
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
+#if 0
static void test_nested()
{
atomic(t)
@@ -35,10 +36,11 @@
++*tx;
} end_atom
}
-
+#endif
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
-void test_parent()
+#if 0
+static void test_parent()
{
atomic(t)
{
@@ -49,7 +51,7 @@
cout << "*tx should be 1, output: " << *tx << endl;
} end_atom
}
-
+#endif
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
static void test_priv_write_ptr()
@@ -124,7 +126,8 @@
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
-void test2()
+#if 0
+static void test2()
{
atomic(t)
{
@@ -136,17 +139,17 @@
//int y = 0;
}
-
+#endif
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void test_smart()
{
- boost::stm::transaction::initialize();
- boost::stm::transaction::initialize_thread();
+ transaction::initialize();
+ transaction::initialize_thread();
- //boost::stm::transaction::do_direct_updating();
- boost::stm::transaction::do_deferred_updating();
+ //transaction::do_direct_updating();
+ transaction::do_deferred_updating();
//test_2();
//test_parent();
Modified: sandbox/stm/branches/vbe/libs/stm/test/stm.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/stm.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/stm.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -1,18 +1,19 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Justin E. Gottchlich 2009.
-// (C) Copyright Vicente J. Botet Escriba 2009.
+// (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
+// 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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
#include <boost/stm/transaction.hpp>
+
#include "main.h"
#include <sstream>
#include <iostream>
@@ -45,10 +46,10 @@
#include "litExample.h"
#endif
-using namespace boost::stm; using namespace nMain; using namespace std;
+using namespace boost; using namespace boost::stm; using namespace nMain; using namespace std;
-boost::stm::native_trans<int> threadsFinished;
-boost::stm::native_trans<int> threadsStarted;
+native_trans<int> threadsFinished;
+native_trans<int> threadsStarted;
time_t startTimer = kStartingTime;
time_t endTimer = 0;
eWorkType gWorkLoadType;
@@ -144,7 +145,7 @@
if (latmType == "full") transaction::do_full_lock_protection();
else if (latmType == "tm") transaction::do_tm_lock_protection();
else if (latmType == "tx") transaction::do_tx_lock_protection();
- else
+ else
{
cout << "invalid LATM protection type, exiting" << endl;
cout << first << latmType << endl;
@@ -205,9 +206,9 @@
//-----------------------------------------------------------------------------
void idleUntilAllThreadsHaveReached(int const &threadId)
{
- lock(&finishLock);
+ synchro::lock(finishLock);
threadsStarted.value()++;
- unlock(&finishLock);
+ synchro::unlock(finishLock);
while (threadsStarted.value() != kMaxThreads) SLEEP(5);
}
@@ -215,17 +216,17 @@
//-----------------------------------------------------------------------------
void finishThread()
{
- lock(&finishLock);
+ synchro::lock(finishLock);
threadsFinished.value()++;
- unlock(&finishLock);
+ synchro::unlock(finishLock);
}
//-----------------------------------------------------------------------------
void finishThread(int const &threadId)
{
- lock(&finishLock);
+ synchro::lock(finishLock);
threadsFinished.value()++;
- unlock(&finishLock);
+ synchro::unlock(finishLock);
}
//-----------------------------------------------------------------------------
@@ -233,14 +234,14 @@
{
ofstream aborts("abortSetSize.txt", std::ios::app);
- transaction_bookkeeping::AbortHistory::const_iterator j =
+ transaction_bookkeeping::AbortHistory::const_iterator j =
transaction::bookkeeping().getAbortWriteSetList().begin();
- transaction_bookkeeping::AbortHistory::const_iterator k =
+ transaction_bookkeeping::AbortHistory::const_iterator k =
transaction::bookkeeping().getAbortReadSetList().begin();
- transaction_bookkeeping::CommitHistory::const_iterator l =
+ transaction_bookkeeping::CommitHistory::const_iterator l =
transaction::bookkeeping().getCommitWriteSetList().begin();
- transaction_bookkeeping::CommitHistory::const_iterator m =
+ transaction_bookkeeping::CommitHistory::const_iterator m =
transaction::bookkeeping().getCommitReadSetList().begin();
std::vector<double> percentList;
@@ -253,7 +254,7 @@
char *space = k->first.commitId_ > 10 ? " " : k->first.commitId_ > 100 ? " " : " ";
aborts << k->first.threadId_ << "\t\t" << space
- << k->first.commitId_ << "\t\t" << k->second << "\t\t" << j->second
+ << k->first.commitId_ << "\t\t" << k->second << "\t\t" << j->second
<< "\t\t\t\t" << m->second << "\t\t" << l->second << "\t\t";
#endif
double percent = double(j->second + k->second) / double(m->second + l->second);
@@ -269,10 +270,10 @@
percentTotal = percentTotal / double(percentList.size());
- uint32 abortCount = transaction::bookkeeping().getAbortReadSetList().size()
+ uint32 abortCount = transaction::bookkeeping().getAbortReadSetList().size()
+ transaction::bookkeeping().getAbortWriteSetList().size();
- aborts << typeOfRun.c_str() << " total_aborts: " << transaction::bookkeeping().totalAborts()
+ aborts << typeOfRun.c_str() << " total_aborts: " << transaction::bookkeeping().totalAborts()
<< "\t\taborted_r+w_count: " << abortCount
<< "\t\tabort_ops/commit_ops: " << percentTotal << endl;
Modified: sandbox/stm/branches/vbe/libs/stm/test/testHT_latm.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testHT_latm.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testHT_latm.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -264,7 +264,7 @@
transaction::initialize();
transaction::initialize_thread();
- //int index = convertThreadIdToLinkedListIndex(k);
+ (void) convertThreadIdToLinkedListIndex(k);
//----------------------------------------------------------------
// every 4th thread works on the same linked list that
Modified: sandbox/stm/branches/vbe/libs/stm/test/testHashMap.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testHashMap.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testHashMap.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
Modified: sandbox/stm/branches/vbe/libs/stm/test/testHashMapAndLinkedListsWithLocks.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testHashMapAndLinkedListsWithLocks.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testHashMapAndLinkedListsWithLocks.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
@@ -156,7 +156,8 @@
}
///////////////////////////////////////////////////////////////////////////////
-void* TestLinkedListInserts(void *threadId)
+#if 0
+static void* TestLinkedListInserts(void *threadId)
{
LATM::list_node<int> node;
transaction::initialize_thread();
@@ -234,7 +235,7 @@
return 0;
}
-
+#endif
///////////////////////////////////////////////////////////////////////////////
static void* TestHashMapInserts(void *threadId)
{
Modified: sandbox/stm/branches/vbe/libs/stm/test/testHashMapWithLocks.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testHashMapWithLocks.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testHashMapWithLocks.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
Modified: sandbox/stm/branches/vbe/libs/stm/test/testInt.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testInt.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testInt.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
Modified: sandbox/stm/branches/vbe/libs/stm/test/testLL_latm.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testLL_latm.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testLL_latm.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
Modified: sandbox/stm/branches/vbe/libs/stm/test/testLinkedList.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testLinkedList.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testLinkedList.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifdef BOOST_STM_LL_USES_NODE
Modified: sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testLinkedListWithLocks.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -34,7 +34,7 @@
public:
list_node() : next_(0), value_(0) {}
- explicit list_node(int const &rhs) : value_(rhs), next_(0) {}
+ explicit list_node(int const &rhs) : next_(0), value_(rhs) {}
// zero initialization for native types
void clear() { value_ = T(); next_ = 0; }
@@ -120,7 +120,7 @@
succeeded2 = internal_insert(node2);
t.end();
}
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
if (!succeeded1 || !succeeded2)
{
@@ -148,7 +148,7 @@
for (; ;t.restart())
{
try { return internal_insert(node, t); }
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
}
}
@@ -168,7 +168,7 @@
for (; ; t.restart())
{
try { return internal_lookup(val, t); }
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
}
}
@@ -265,7 +265,7 @@
for (transaction t; ; t.restart())
{
try { return internal_remove(node, t); }
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
}
}
@@ -326,7 +326,7 @@
t.write(head_).clear();
t.end();
}
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
}
}
Modified: sandbox/stm/branches/vbe/libs/stm/test/testPerson.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testPerson.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testPerson.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
Modified: sandbox/stm/branches/vbe/libs/stm/test/testRBTree.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testRBTree.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testRBTree.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
Modified: sandbox/stm/branches/vbe/libs/stm/test/testRBTree.h
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/testRBTree.h (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/testRBTree.h 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -56,7 +56,7 @@
////////////////////////////////////////////////////////////////////////////
RedBlackNode() : color_(nRedBlackTree::eRed), value_(T()),
- left_(&sentinel), right_(&sentinel), parent_(&sentinel) {}
+ left_(&sentinel), right_(&sentinel), parent_(&sentinel) {}
T const & const_value(boost::stm::transaction &t) const
{ return t.read(*const_cast<RedBlackNode<T>*>(this)).value_; }
@@ -153,7 +153,7 @@
for (transaction t; ; t.restart())
{
try { return internal_insert(node, t); }
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
}
}
@@ -165,7 +165,7 @@
for (transaction t; ; t.restart())
{
try { return internal_lookup(v, found, t); }
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
}
}
@@ -618,7 +618,7 @@
for (transaction t; ; t.restart())
{
try { return internal_remove(inNode, t); }
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
}
}
Modified: sandbox/stm/branches/vbe/libs/stm/test/transferFun.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/transferFun.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/transferFun.cpp 2009-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -7,7 +7,7 @@
// (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.
+// See http://www.boost.org/libs/stm for documentation.
//
//////////////////////////////////////////////////////////////////////////////
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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -14,6 +14,8 @@
#include <sstream>
#include "usingLockTx.h"
+using namespace std;
+
typedef int list_node_type;
static newSyntaxNS::LinkedList< list_node_type > *llist = 0;
@@ -31,7 +33,6 @@
#endif
using namespace boost::stm;
-using namespace std;
static native_trans<int> x = 0;
static native_trans<int> y = 0;
@@ -109,11 +110,12 @@
////////////////////////////////////////////////////////////////////////////
-using namespace std; using namespace boost::stm;
+using namespace std;
using namespace nMain;
///////////////////////////////////////////////////////////////////////////////
-void* TestLinkedListInsertsWithLocksBis(void *threadId)
+#if 0
+static void* TestLinkedListInsertsWithLocks(void *threadId)
{
newSyntaxNS::list_node<list_node_type> node;
transaction::initialize_thread();
@@ -193,9 +195,10 @@
return 0;
}
-
+#endif
///////////////////////////////////////////////////////////////////////////////
-void* TestLinkedListInsertsBis(void *threadId)
+#if 0
+static void* TestLinkedListInserts(void *threadId)
{
newSyntaxNS::list_node<list_node_type> node;
transaction::initialize_thread();
@@ -275,7 +278,7 @@
return 0;
}
-
+#endif
///////////////////////////////////////////////////////////////////////////////
@@ -293,6 +296,7 @@
}
///////////////////////////////////////////////////////////////////////////////
+#if 0
static void TestNested2()
{
atomic(t)
@@ -306,9 +310,10 @@
}
}
-
+#endif
///////////////////////////////////////////////////////////////////////////////
-void TestNested()
+#if 0
+static void TestNested()
{
atomic(t)
{
@@ -320,11 +325,12 @@
cout << "TestNested caught exception" << endl;
}
}
+#endif
///////////////////////////////////////////////////////////////////////////////
static void TestTransactionInsideLock()
{
- using namespace boost::stm;
+ //using namespace boost::stm;
cout << "X: " << x.value() << endl;
@@ -349,11 +355,10 @@
cout << "X: " << x.value() << endl;
}
-
///////////////////////////////////////////////////////////////////////////////
static void TestEarlyRelease()
{
- using namespace boost::stm;
+ //using namespace boost::stm;
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-10-17 10:43:40 EDT (Sat, 17 Oct 2009)
@@ -121,7 +121,7 @@
succeeded2 = internal_insert(node2);
t.end();
}
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
if (!succeeded1 || !succeeded2)
{
@@ -265,7 +265,7 @@
for (transaction t; ; t.restart())
{
try { return internal_remove(node, t); }
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
}
}
@@ -326,7 +326,7 @@
t.write(head_).clear();
t.end();
}
- catch (boost::stm::aborted_transaction_exception&) {}
+ catch (aborted_transaction_exception&) {}
}
}
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