|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60584 - in sandbox/stm/branches/vbe/boost/stm: . detail latm tx
From: vicente.botet_at_[hidden]
Date: 2010-03-14 17:33:17
Author: viboes
Date: 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
New Revision: 60584
URL: http://svn.boost.org/trac/boost/changeset/60584
Log:
Boost.STM/vbe/:
* Added invariants
* Use of call context to trace who is locking which mutex
* Fix two bugs in flight erase was not protected in one case, and deferred_abort didn't erase the transaction correctly.
* cleanup
Text files modified:
sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 68 ++--
sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp | 40 +-
sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp | 44 ++-
sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp | 34 +-
sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp | 40 ++-
sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp | 44 ++-
sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp | 38 +-
sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp | 38 +-
sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp | 484 ++++++++++++++++++++++++---------------
sandbox/stm/branches/vbe/boost/stm/detail/transactions_stack.hpp | 4
sandbox/stm/branches/vbe/boost/stm/latm/all_in_one_mode.hpp | 4
sandbox/stm/branches/vbe/boost/stm/latm/base_mode.hpp | 3
sandbox/stm/branches/vbe/boost/stm/latm/tm_mode.hpp | 5
sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 321 +++++++++++++++++++-------
sandbox/stm/branches/vbe/boost/stm/tx/proxy_cache.hpp | 38 ++
15 files changed, 772 insertions(+), 433 deletions(-)
Modified: sandbox/stm/branches/vbe/boost/stm/detail/config.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/config.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/config.hpp 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -14,6 +14,8 @@
#ifndef BOOST_STM_DETAIL_CONFIG_H
#define BOOST_STM_DETAIL_CONFIG_H
+#include <boost/synchro/detail/config.hpp>
+
#ifdef WIN32
#define WINOS
#elif WIN64
@@ -30,12 +32,12 @@
///////////////////////////////////////////////////////////////////////////////
-//#define DELAY_INVALIDATION_DOOMED_TXS_UNTIL_COMMIT
-//#define PERFORMING_VALIDATION 1
+//~ #define DELAY_INVALIDATION_DOOMED_TXS_UNTIL_COMMIT
+//~ #define PERFORMING_VALIDATION 1
#define PERFORMING_COMPOSITION 1
#define PERFORMING_LATM 1
#define USING_TRANSACTION_SPECIFIC_LATM 1
-//#define ALWAYS_ALLOW_ABORT 1
+//~ #define ALWAYS_ALLOW_ABORT 1
#define USING_SHARED_FORCED_TO_ABORT 1
@@ -46,7 +48,7 @@
// OTHER: each TSS data has its specific TSS
#define USE_SINGLE_THREAD_CONTEXT_MAP 1
-//#define BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP 1
+//~ #define BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP 1
///////////////////////////////////////////////////////////////////////////////
@@ -60,14 +62,14 @@
// BOOST_STM_CM_STATIC_CONF when you want a staticacly configured CM
// BOOST_STM_CM_DYNAMIC_CONF when you want a polymorphic CM configured at run time
-//#define BOOST_STM_CM_STATIC_CONF 1
-//#define BOOST_STM_CM_DYNAMIC_CONF 1
+//~ #define BOOST_STM_CM_STATIC_CONF 1
+//~ #define BOOST_STM_CM_DYNAMIC_CONF 1
// Define only one of
// BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm when configuration manager is except_and_back_off_on_abort_notice_cm
#define BOOST_STM_CM_STATIC_CONF <boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp>
-//#define BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm 1
+//~ #define BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm 1
#define BOOST_STM_CM_STATIC_INITIAL_SLEEP_TIME 0
#define BOOST_STM_CM_STATIC_SLEEP_INCREASE 0
@@ -80,9 +82,9 @@
//// BOOST_STM_USE_GLOBAL_MEMORY_MANAGER: uses the global memory manager
//// BOOST_STM_USE_CLASS_MEMORY_MANAGER: uses the class specific memory manager
-//#define BOOST_STM_USE_DEFAULT_MEMORY_MANAGER 1
-//#define BOOST_STM_USE_GLOBAL_MEMORY_MANAGER 1
-//#define BOOST_STM_USE_CLASS_MEMORY_MANAGER 1
+//~ #define BOOST_STM_USE_DEFAULT_MEMORY_MANAGER 1
+//~ #define BOOST_STM_USE_GLOBAL_MEMORY_MANAGER 1
+//~ #define BOOST_STM_USE_CLASS_MEMORY_MANAGER 1
#if (defined(BOOST_STM_USE_DEFAULT_MEMORY_MANAGER) && defined(BOOST_STM_USE_GLOBAL_MEMORY_MANAGER)) || \
(defined(BOOST_STM_USE_GLOBAL_MEMORY_MANAGER) && defined(BOOST_STM_USE_CLASS_MEMORY_MANAGER)) || \
@@ -106,11 +108,11 @@
#define BOOST_STM_CACHE_USE_MALLOC 1
#if defined(BOOST_STM_USE_GLOBAL_MEMORY_MANAGER)
-//#define BOOST_STM_CACHE_USE_MEMORY_MANAGER 1
+//~ #define BOOST_STM_CACHE_USE_MEMORY_MANAGER 1
#endif
-//#define BOOST_STM_CACHE_USE_CLASS_MEMORY_MANAGER 1
+//~ #define BOOST_STM_CACHE_USE_CLASS_MEMORY_MANAGER 1
#if defined(USE_SINGLE_THREAD_CONTEXT_MAP)
-//#define BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER 1
+//~ #define BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER 1
#endif
#if defined(BOOST_STM_CACHE_USE_MALLOC) || defined(BOOST_STM_CACHE_USE_MEMORY_MANAGER) || defined(BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER)
@@ -137,10 +139,10 @@
#define MAP_WRITE_CONTAINER 1
///////////////////////////////////////////////////////////////////////////////
// define MAP_NEW_CONTAINER if you want STM uses flat map for new set
-//#define MAP_NEW_CONTAINER 1
+//~ #define MAP_NEW_CONTAINER 1
///////////////////////////////////////////////////////////////////////////////
// define MAP_THREAD_MUTEX_CONTAINER if you want STM uses flat map for thread mutex set
-//#define MAP_THREAD_MUTEX_CONTAINER 1
+//~ #define MAP_THREAD_MUTEX_CONTAINER 1
///////////////////////////////////////////////////////////////////////////////
// define MAP_THREAD_BOOL_CONTAINER if you want STM uses flat map for thread bool set
#define MAP_THREAD_BOOL_CONTAINER 1
@@ -151,11 +153,11 @@
#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
-//#define BOOST_STM_T_USE_BOOST_MUTEX 1
+//~ #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
+//~ #define BOOST_STM_T_USE_BOOST_MUTEX 1
#endif
///////////////////////////////////////////////////////////////////////////////
@@ -163,7 +165,7 @@
///////////////////////////////////////////////////////////////////////////////
#define BOOST_STM_NO_PARTIAL_SPECIALIZATION 1
///////////////////////////////////////////////////////////////////////////////
-#define BUILD_MOVE_SEMANTICS 0
+//~ #define BUILD_MOVE_SEMANTICS 1
///////////////////////////////////////////////////////////////////////////////
// Define BOOST_STM_ALLOWS_EMBEDEEDS when you want embeed TO
@@ -180,10 +182,10 @@
// BOOST_STM_LATM_STATIC_TX_MODE
// BOOST_STM_LATM_DYNAMIC_MODE
-//#define BOOST_STM_LATM_STATIC_FULL_MODE 1
-//#define BOOST_STM_LATM_STATIC_TM_MODE 1
-//#define BOOST_STM_LATM_STATIC_TX_MODE 1
-//#define BOOST_STM_LATM_DYNAMIC_MODE 1
+//~ #define BOOST_STM_LATM_STATIC_FULL_MODE 1
+//~ #define BOOST_STM_LATM_STATIC_TM_MODE 1
+//~ #define BOOST_STM_LATM_STATIC_TX_MODE 1
+//~ #define BOOST_STM_LATM_DYNAMIC_MODE 1
#if defined(BOOST_STM_LATM_STATIC_FULL_MODE) || defined(BOOST_STM_LATM_STATIC_TM_MODE) || defined(BOOST_STM_LATM_STATIC_TX_MODE)
#define BOOST_STM_LATM_STATIC_MODE 1
@@ -197,16 +199,14 @@
///////////////////////////////////////////////////////////////////////////////
// Define BOOST_STM_COMMITS_BEFORE_RETURN if the macros RETURN must commit before returning
-//#define BOOST_STM_COMMITS_BEFORE_RETURN 1
-
-///////////////////////////////////////////////////////////////////////////////
-#endif // BOOST_STM_DETAIL_CONFIG_H
-
-
-
-
-
+//~ #define BOOST_STM_COMMITS_BEFORE_RETURN 1
+//~ #define BOOST_STM_USE_STACK 1
+#ifdef BOOST_STM_USES_CALL_CONTEXT
+#define BOOST_STM_USE_INVARIANT 1
+#endif
+///////////////////////////////////////////////////////////////////////////////
+#endif // BOOST_STM_DETAIL_CONFIG_H
Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -52,14 +52,15 @@
inline bool transaction::def_do_core_full_pthread_lock_mutex
(latm::mutex_type* mutex, int lockWaitTime, int lockAborted)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
//--------------------------------------------------------------------------
// if the lock-aware tm lock set is empty, lock the in-flight trans mutex
// so we can abort all the in-flight transactions
//--------------------------------------------------------------------------
if (latm::instance().latmLockedLocks_.empty())
{
- synchro::lock_guard<Mutex> lk_g(*general_lock());
- synchro::lock_guard<Mutex> lk_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
std::list<transaction*> txList;
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
@@ -68,6 +69,7 @@
BOOST_ASSERT(*i!=0);
//~ (*i)->assert_tx_type();
transaction *t = *i;
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
if (!t->irrevocable() &&
cm_allow_lock_to_abort_tx(lockWaitTime, lockAborted, false, *t))
@@ -83,7 +85,7 @@
for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
{
BOOST_ASSERT(*it!=0);
-
+
(*it)->force_to_abort();
}
}
@@ -96,11 +98,13 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::def_full_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
t->make_isolated();
bool hadLock = t->is_currently_locked_lock(&mutex);
@@ -109,12 +113,12 @@
t->commit_deferred_update_tx();
{
- synchro::lock_guard<Mutex> lk_l(*latm_lock());
+ synchro::lock_guard<Mutex> lk_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
latm::instance().latmLockedLocksOfThreadMap_[&mutex] = this_thread::get_id();
}
if (hadLock) return;
- else synchro::lock(m);
+ else synchro::lock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
return;
}
@@ -122,8 +126,8 @@
for (;;)
{
{
- synchro::unique_lock<M> lk(m);
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::unique_lock<M> lk(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//--------------------------------------------------------------------
// if we are able to do the core lock work, break
//--------------------------------------------------------------------
@@ -149,11 +153,13 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline bool transaction::def_full_try_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
t->make_isolated();
bool hadLock = t->is_currently_locked_lock(&mutex);
@@ -162,7 +168,7 @@
t->commit_deferred_update_tx();
{
- synchro::lock_guard<Mutex> lk_l(*latm_lock());
+ synchro::lock_guard<Mutex> lk_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
latm::instance().latmLockedLocksOfThreadMap_[&mutex] = this_thread::get_id();
}
@@ -170,10 +176,10 @@
else return synchro::try_lock(m);
}
- synchro::unique_lock<M> lk(m, synchro::try_to_lock);
+ synchro::unique_lock<M> lk(m, synchro::try_to_lock BOOST_STM_CALL_CONTEXT("glatm_lock"));
if (!lk) return false;
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//-----------------------------------------------------------------------
// if !core done, since trylock, we cannot stall & retry - just exit
@@ -193,15 +199,17 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::def_full_unlock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
bool hasLock = true;
{
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
if (!t->is_on_obtained_locks_list(&mutex))
{
// this is illegal, it means the transaction is unlocking a lock
@@ -216,12 +224,12 @@
latm::instance().latmLockedLocks_.erase(&mutex);
- if (latm::instance().latmLockedLocks_.empty()) synchro::unlock(*inflight_lock());
+ if (latm::instance().latmLockedLocks_.empty()) synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
latm::instance().latmLockedLocksOfThreadMap_.erase(&mutex);
}
- if (hasLock) synchro::unlock(m);
+ if (hasLock) synchro::unlock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
return;
}
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 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -52,7 +52,8 @@
inline bool transaction::def_do_core_tm_conflicting_lock_pthread_lock_mutex
(latm::mutex_type* mutex, int lockWaitTime, int lockAborted)
{
- //--------------------------------------------------------------------------
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+//--------------------------------------------------------------------------
// if this mutex is on the tmConflictingLocks_ set, then we need to stop
// transactions which are in-flight.
//
@@ -64,8 +65,8 @@
// so we can abort all the in-flight transactions
if (latm::instance().latmLockedLocks_.empty())
{
- synchro::lock_guard<Mutex> lk_g(*general_lock());
- synchro::lock_guard<Mutex> lk_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
std::list<transaction*> txList;
@@ -75,6 +76,7 @@
BOOST_ASSERT(*i!=0);
//~ (*i)->assert_tx_type();
transaction *t = *i;
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
if (!t->irrevocable() &&
cm_allow_lock_to_abort_tx(lockWaitTime, lockAborted, false, *t))
@@ -87,7 +89,7 @@
for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
{
BOOST_ASSERT(*it!=0);
-
+
(*it)->force_to_abort();
}
}
@@ -101,11 +103,14 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::def_tm_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
+
latm::instance().must_be_in_tm_conflicting_lock_set(&mutex);
t->make_isolated();
t->commit_deferred_update_tx();
@@ -114,12 +119,12 @@
t->add_to_currently_locked_locks(&mutex);
{
- synchro::lock_guard<Mutex> lk_l(*latm_lock());
+ synchro::lock_guard<Mutex> lk_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
latm::instance().latmLockedLocksOfThreadMap_[&mutex] = this_thread::get_id();
}
if (hadLock) return;
- else synchro::lock(m);
+ else synchro::lock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
return;
}
@@ -128,8 +133,8 @@
for (;;)
{
{
- synchro::unique_lock<M> lk(m);
- synchro::lock_guard<Mutex> lk_l(*latm_lock());
+ synchro::unique_lock<M> lk(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
+ synchro::lock_guard<Mutex> lk_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
//--------------------------------------------------------------------
// if we are able to do the core lock work, break
@@ -156,11 +161,14 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline bool transaction::def_tm_try_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
+
latm::instance().must_be_in_tm_conflicting_lock_set(&mutex);
t->make_isolated();
t->commit_deferred_update_tx();
@@ -169,7 +177,7 @@
t->add_to_currently_locked_locks(&mutex);
{
- synchro::lock_guard<Mutex> lk_l(*latm_lock());
+ synchro::lock_guard<Mutex> lk_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
latm::instance().latmLockedLocksOfThreadMap_[&mutex] = this_thread::get_id();
}
@@ -177,10 +185,10 @@
else return synchro::try_lock(m);
}
- synchro::unique_lock<M> lk(m, synchro::try_to_lock);
+ synchro::unique_lock<M> lk(m, synchro::try_to_lock BOOST_STM_CALL_CONTEXT("glatm_lock"));
if (!lk) return false;
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//-----------------------------------------------------------------------
// if !core done, since trylock, we cannot stall & retry - just exit
@@ -200,15 +208,17 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::def_tm_unlock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
bool hasLock = true;
{
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
if (!t->is_on_obtained_locks_list(&mutex))
{
// this is illegal, it means the transaction is unlocking a lock
@@ -230,13 +240,13 @@
{
latm::instance().latmLockedLocks_.erase(&mutex);
- if (latm::instance().latmLockedLocks_.empty()) synchro::unlock(*inflight_lock());
+ if (latm::instance().latmLockedLocks_.empty()) synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
}
latm::instance().latmLockedLocksOfThreadMap_.erase(&mutex);
}
- if (hasLock) synchro::unlock(m);
+ if (hasLock) synchro::unlock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
return;
}
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 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -44,14 +44,15 @@
inline bool transaction::def_do_core_tx_conflicting_lock_pthread_lock_mutex
(latm::mutex_type* mutex, int lockWaitTime, int lockAborted, bool txIsIrrevocable)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
//--------------------------------------------------------------------------
// see if this mutex is part of any of the in-flight transactions conflicting
// mutex set. if it is, stop that transaction and add it to the latm conflicting
// set. do not keep in-flight transactions blocked once the transactions have
// been processed.
//--------------------------------------------------------------------------
- synchro::lock_guard<Mutex> lk_g(*general_lock());
- synchro::lock_guard<Mutex> lk_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
std::list<transaction *> txList;
std::set<thread_id_t> txThreadId;
@@ -125,9 +126,10 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::def_tx_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
int waitTime = 0, aborted = 0;
//--------------------------------------------------------------------------
@@ -157,14 +159,14 @@
if (!t->is_currently_locked_lock(&mutex))
{
- synchro::lock(m);
+ synchro::lock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
}
t->add_to_currently_locked_locks(&mutex);
t->add_to_obtained_locks(&mutex);
t->commit_deferred_update_tx();
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
def_do_core_tx_conflicting_lock_pthread_lock_mutex(&mutex, 0, 0, true);
return;
}
@@ -172,8 +174,8 @@
for (;;)
{
{
- synchro::unique_lock<M> lk(m);
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::unique_lock<M> lk(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//--------------------------------------------------------------------
// if we are able to do the core lock work, break
@@ -202,19 +204,20 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline bool transaction::def_tx_try_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
//--------------------------------------------------------------------------
BOOST_ASSERT(false&& "might not be possible to implement trylock for this");
bool txIsIrrevocable = false;
- synchro::unique_lock<M> lk(m, synchro::try_to_lock);
+ synchro::unique_lock<M> lk(m, synchro::try_to_lock BOOST_STM_CALL_CONTEXT("glatm_lock"));
if (!lk) return false;
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
@@ -244,12 +247,13 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::def_tx_unlock(M& m, latm::mutex_type& mutex)
{
- synchro::lock_guard<Mutex> lk_l(*latm_lock());
- synchro::lock_guard<Mutex> lk_g(*general_lock());
- synchro::lock_guard<Mutex> lk_i(*inflight_lock());
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+ synchro::lock_guard<Mutex> lk_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
+ synchro::lock_guard<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
bool hasLock = true;
if (transaction* t = get_inflight_tx_of_same_thread(true))
@@ -289,7 +293,7 @@
latm::instance().latmLockedLocksOfThreadMap_.erase(&mutex);
unblock_threads_if_locks_are_empty();
- if (hasLock) synchro::unlock(m);
+ if (hasLock) synchro::unlock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
return;
}
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 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -52,6 +52,8 @@
inline bool transaction::dir_do_core_full_pthread_lock_mutex
(latm::mutex_type* mutex, int lockWaitTime, int lockAborted)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+
//--------------------------------------------------------------------------
// if the lock-aware tm lock set is empty, lock the in-flight trans mutex
// so we can abort all the in-flight transactions
@@ -60,8 +62,8 @@
{
{
- synchro::lock_guard<Mutex> lk_g(*general_lock());
- synchro::lock_guard<Mutex> lk_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
std::list<transaction*> txList;
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
@@ -70,6 +72,7 @@
BOOST_ASSERT(*i!=0);
//~ (*i)->assert_tx_type();
transaction *t = *i;
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
if (!t->irrevocable() &&
cm_allow_lock_to_abort_tx(lockWaitTime, lockAborted, false, *t))
@@ -85,7 +88,7 @@
for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
{
BOOST_ASSERT(*it!=0);
-
+
(*it)->force_to_abort();
}
@@ -120,11 +123,14 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::dir_full_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
+
t->make_isolated();
bool hadLock = t->is_currently_locked_lock(&mutex);
@@ -134,7 +140,7 @@
wait_until_all_locks_are_released_and_set(&mutex);
if (hadLock) return;
- else synchro::lock(m);
+ else synchro::lock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
return;
}
@@ -142,8 +148,8 @@
for (;;)
{
{
- synchro::unique_lock<M> lk(m);
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::unique_lock<M> lk(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//--------------------------------------------------------------------
// if we are able to do the core lock work, break
@@ -169,11 +175,14 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline bool transaction::dir_full_try_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
+
t->make_isolated();
bool hadLock = t->is_currently_locked_lock(&mutex);
@@ -186,9 +195,9 @@
else return synchro::try_lock(m);
}
- synchro::unique_lock<M> lk(m, synchro::try_to_lock);
+ synchro::unique_lock<M> lk(m, synchro::try_to_lock BOOST_STM_CALL_CONTEXT("glatm_lock"));
if (!lk) return false;
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//-----------------------------------------------------------------------
// if !core done, since trylock, we cannot stall & retry - just exit
@@ -208,15 +217,18 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::dir_full_unlock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
bool hasLock = true;
{
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
+
if (!t->is_on_obtained_locks_list(&mutex))
{
// this is illegal, it means the transaction is unlocking a lock
@@ -233,13 +245,13 @@
if (latm::instance().latmLockedLocks_.empty())
{
- synchro::lock_guard<Mutex> lk_g(*general_lock());
+ synchro::lock_guard<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
thread_conflicting_mutexes_set_all(false);
}
latm::instance().latmLockedLocksOfThreadMap_.erase(&mutex);
}
- if (hasLock) synchro::unlock(m);
+ if (hasLock) synchro::unlock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
return;
}
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 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -52,6 +52,8 @@
inline bool transaction::dir_do_core_tm_conflicting_lock_pthread_lock_mutex
(latm::mutex_type* mutex, int lockWaitTime, int lockAborted)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+
//--------------------------------------------------------------------------
// if this mutex is on the tmConflictingLocks_ set, then we need to stop
// transactions which are in-flight.
@@ -67,8 +69,8 @@
if (latm::instance().latmLockedLocks_.empty())
{
{
- synchro::lock_guard<Mutex> lk_g(*general_lock());
- synchro::lock_guard<Mutex> lk_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
std::list<transaction*> txList;
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
@@ -77,6 +79,7 @@
BOOST_ASSERT(*i!=0);
//~ (*i)->assert_tx_type();
transaction *t = *i;
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
if (!t->irrevocable() &&
cm_allow_lock_to_abort_tx(lockWaitTime, lockAborted, false, *t))
@@ -92,7 +95,7 @@
for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
{
BOOST_ASSERT(*it!=0);
-
+
(*it)->force_to_abort();
}
@@ -119,18 +122,21 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::dir_tm_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
+
latm::instance().must_be_in_tm_conflicting_lock_set(&mutex);
t->make_isolated();
{
- synchro::lock_guard<Mutex> lk_l(*latm_lock());
+ synchro::lock_guard<Mutex> lk_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
latm::instance().latmLockedLocksOfThreadMap_[&mutex] = this_thread::get_id();
}
- synchro::lock(m); // BUG: should't be before the map setting and making the tx isolated?
+ synchro::lock(m BOOST_STM_CALL_CONTEXT("glatm_lock")); // BUG: should't be before the map setting and making the tx isolated?
return;
}
@@ -139,8 +145,8 @@
for (;;)
{
{
- synchro::unique_lock<M> lk(m);
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::unique_lock<M> lk(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//--------------------------------------------------------------------
// if we are able to do the core lock work, break
@@ -168,23 +174,26 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline bool transaction::dir_tm_try_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
+
latm::instance().must_be_in_tm_conflicting_lock_set(&mutex);
t->make_isolated();
{
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
latm::instance().latmLockedLocksOfThreadMap_[&mutex] = this_thread::get_id();
}
return synchro::try_lock(m); // BUG: : should't be before the map setting and making the tx isolated?
}
- synchro::unique_lock<M> lk(m, synchro::try_to_lock);
+ synchro::unique_lock<M> lk(m, synchro::try_to_lock BOOST_STM_CALL_CONTEXT("glatm_lock"));
if (!lk) return false;
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//-----------------------------------------------------------------------
// if !core done, since trylock, we cannot stall & retry - just exit
@@ -204,15 +213,18 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::dir_tm_unlock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
bool hasLock = true;
{
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(t);
+
if (!t->is_on_obtained_locks_list(&mutex))
{
// this is illegal, it means the transaction is unlocking a lock
@@ -236,7 +248,7 @@
if (latm::instance().latmLockedLocks_.empty())
{
- synchro::lock_guard<Mutex> lk_g(*general_lock());
+ synchro::lock_guard<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
thread_conflicting_mutexes_set_all(false);
}
}
@@ -244,7 +256,7 @@
latm::instance().latmLockedLocksOfThreadMap_.erase(&mutex);
}
- if (hasLock) synchro::unlock(m);
+ if (hasLock) synchro::unlock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
return;
}
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 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -45,14 +45,15 @@
inline bool transaction::dir_do_core_tx_conflicting_lock_pthread_lock_mutex
(latm::mutex_type* mutex, int lockWaitTime, int lockAborted, bool txIsIrrevocable)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
//--------------------------------------------------------------------------
// see if this mutex is part of any of the in-flight transactions conflicting
// mutex set. if it is, stop that transaction and add it to the latm conflicting
// set. do not keep in-flight transactions blocked once the transactions have
// been processed.
//--------------------------------------------------------------------------
- synchro::unique_lock<Mutex> lk_g(*general_lock());
- synchro::unique_lock<Mutex> lk_i(*inflight_lock());
+ synchro::unique_lock<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unique_lock<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
std::list<transaction *> txList;
std::set<thread_id_t> txThreadId;
@@ -125,8 +126,8 @@
bool conflictingTxInFlight = false;
{
- synchro::unique_lock<Mutex> lk_g(*general_lock());
- synchro::unique_lock<Mutex> lk_i(*inflight_lock());
+ synchro::unique_lock<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unique_lock<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
i != in_flight_transactions().end(); ++i)
@@ -156,9 +157,10 @@
// Protected by: mutex is locked
// Postcondition: mutex is locked
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::dir_tx_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
int waitTime = 0, aborted = 0;
//--------------------------------------------------------------------------
@@ -188,13 +190,13 @@
if (!t->is_currently_locked_lock(&mutex))
{
- synchro::lock(m);
+ synchro::lock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
}
t->add_to_currently_locked_locks(&mutex);
t->add_to_obtained_locks(&mutex);
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
def_do_core_tx_conflicting_lock_pthread_lock_mutex(&mutex, 0, 0, true);
return;
@@ -203,8 +205,8 @@
for (;;)
{
{
- synchro::unique_lock<M> lk(m);
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::unique_lock<M> lk(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//--------------------------------------------------------------------
// if we are able to do the core lock work, break
@@ -233,17 +235,18 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline bool transaction::dir_tx_try_lock(M& m, latm::mutex_type& mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
//--------------------------------------------------------------------------
throw invalid_operation("might not be possible to implement trylock for this");
bool txIsIrrevocable = false;
- synchro::unique_lock<M> lk(m, synchro::try_to_lock);
+ synchro::unique_lock<M> lk(m, synchro::try_to_lock BOOST_STM_CALL_CONTEXT("glatm_lock"));
if (!lk) return false;
- synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_);
+ synchro::lock_guard<Mutex> lk_l(latm::instance().latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
if (transaction* t = get_inflight_tx_of_same_thread(false))
{
@@ -269,12 +272,13 @@
//----------------------------------------------------------------------------
// only allow one thread to execute any of these methods at a time
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void transaction::dir_tx_unlock(M& m, latm::mutex_type& mutex)
{
- synchro::lock_guard<Mutex> lk_l(*latm_lock());
- synchro::lock_guard<Mutex> lk_g(*general_lock());
- synchro::lock_guard<Mutex> lk_i(*inflight_lock());
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+ synchro::lock_guard<Mutex> lk_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
+ synchro::lock_guard<Mutex> lk_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
bool hasLock = true;
if (transaction* t = get_inflight_tx_of_same_thread(true))
@@ -305,7 +309,7 @@
latm::instance().latmLockedLocksOfThreadMap_.erase(&mutex);
unblock_threads_if_locks_are_empty();
- if (hasLock) synchro::unlock(m);
+ if (hasLock) synchro::unlock(m BOOST_STM_CALL_CONTEXT("glatm_lock"));
return;
}
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 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -48,10 +48,12 @@
//----------------------------------------------------------------------------
inline void boost::stm::transaction::wait_until_all_locks_are_released()
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+
while (true)
{
{
- synchro::lock_guard<Mutex> lk(*latm_lock());
+ synchro::lock_guard<Mutex> lk(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
if (latm::instance().latmLockedLocks_.empty()) {
return;
}
@@ -65,10 +67,12 @@
inline void boost::stm::transaction::wait_until_all_locks_are_released_and_set(latm::mutex_type* mutex)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+
while (true)
{
{
- synchro::lock_guard<Mutex> lk(*latm_lock());
+ synchro::lock_guard<Mutex> lk(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
if (latm::instance().latmLockedLocks_.empty()) {
latm::instance().latmLockedLocksOfThreadMap_[mutex] = this_thread::get_id();
return;
@@ -163,7 +167,7 @@
tss_context_map_.end() != iter; ++iter)
{
BOOST_ASSERT(iter->second!=0);
-
+
if (iter->second->obtainedLocks_.find(mutex) != iter->second->obtainedLocks_.end())
{
return true;
@@ -242,7 +246,7 @@
#else
if (!latm::instance().doing_tm_lock_protection()) return;
- synchro::lock_guard<Mutex> lock_l(latmMutex_);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//-------------------------------------------------------------------------
// insert can throw an exception
@@ -257,7 +261,7 @@
//----------------------------------------------------------------------------
inline void boost::stm::transaction::clear_tm_conflicting_locks()
{
- synchro::lock_guard<Mutex> lock_l(latmMutex_);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
tmConflictingLocks_.clear();
}
@@ -288,12 +292,14 @@
template <typename MP>
inline void boost::stm::transaction::add_tx_conflicting_lock(MP* inLock)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+
if (!latm::instance().doing_tx_lock_protection()) return;
{
- synchro::lock_guard<Mutex> autolock_l(*latm_lock());
- synchro::lock_guard<Mutex> autolock_g(*general_lock());
- synchro::lock_guard<Mutex> autolock_i(*inflight_lock());
+ synchro::lock_guard<Mutex> autolock_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
+ synchro::lock_guard<Mutex> autolock_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> autolock_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
if (get_tx_conflicting_locks().find(&inLock->the_poly_lock()) != get_tx_conflicting_locks().end()) return;
get_tx_conflicting_locks().insert(&inLock->the_poly_lock());
@@ -314,7 +320,8 @@
//----------------------------------------------------------------------------
inline void boost::stm::transaction::clear_tx_conflicting_locks()
{
- synchro::lock_guard<Mutex> lock_l(*general_lock());
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+ synchro::lock_guard<Mutex> lock_l(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
get_tx_conflicting_locks().clear();
}
@@ -325,7 +332,7 @@
// the client chose
//
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void boost::stm::transaction::lock(M& m, latm::mutex_type& mutex)
{
//using namespace boost::stm;
@@ -349,7 +356,7 @@
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline bool boost::stm::transaction::try_lock(M& m, latm::mutex_type& mutex)
{
//using namespace boost::stm;
@@ -372,7 +379,7 @@
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
-template <typename M>
+template <typename M>
inline void boost::stm::transaction::unlock(M& m, latm::mutex_type& mutex)
{
//using namespace boost::stm;
@@ -439,7 +446,7 @@
this_thread::get_id() != l->second)
{
latm::mutex_thread_id_set_map::iterator locksAndThreadsIter = latm::instance().latmLockedLocksAndThreadIdsMap_.find(*k);
-
+
if (locksAndThreadsIter == latm::instance().latmLockedLocksAndThreadIdsMap_.end())
{
ThreadIdSet s;
@@ -484,12 +491,13 @@
inline boost::stm::transaction* boost::stm::transaction::get_inflight_tx_of_same_thread
(bool hasTxInFlightMutex)
{
- synchro::lock_guard_if<Mutex> lock_l(*general_lock(), !hasTxInFlightMutex);
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+ synchro::lock_guard_if<Mutex> lock_l(*general_lock(), !hasTxInFlightMutex BOOST_STM_CALL_CONTEXT("general_lock"));
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
i != in_flight_transactions().end(); ++i)
{
- BOOST_ASSERT(*i!=0);
+ BOOST_ASSERT(*i!=0);
//~ (*i)->assert_tx_type();
transaction *t = *i;
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 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -44,14 +44,13 @@
//--------------------------------------------------------------------------
inline bool transaction::isolatedTxInFlight()
{
- //~ BOOST_STM_INFO<<std::endl;
- //~ assert_tx_type();
+BOOST_STM_TRANSACTION_INVARIANT;
//~ BOOST_STM_INFO<<std::endl;
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
i != in_flight_transactions().end(); ++i)
{
BOOST_ASSERT(*i!=0);
- //~ (*i)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*i);
//~ BOOST_STM_INFO<<std::endl;
// if this is our threadId, skip it
@@ -73,11 +72,12 @@
//--------------------------------------------------------------------------
inline bool transaction::irrevocableTxInFlight()
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
i != in_flight_transactions().end(); ++i)
{
BOOST_ASSERT(*i!=0);
- //~ (*i)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*i);
// if this is our threadId, skip it
if ((*i)->threadId_ == this->threadId_) continue;
@@ -95,11 +95,12 @@
//--------------------------------------------------------------------------
inline bool transaction::abortAllInFlightTxs()
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
i != in_flight_transactions().end(); ++i)
{
BOOST_ASSERT(*i!=0);
- //~ (*i)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*i);
// if this is our threadId, skip it
if ((*i)->threadId_ == this->threadId_) continue;
@@ -116,11 +117,12 @@
//--------------------------------------------------------------------------
inline bool transaction::canAbortAllInFlightTxs()
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
i != in_flight_transactions().end(); ++i)
{
BOOST_ASSERT(*i!=0);
- //~ (*i)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*i);
// if this is our threadId, skip it
if ((*i)->threadId_ == this->threadId_) continue;
@@ -134,6 +136,7 @@
//--------------------------------------------------------------------------
inline void transaction::make_irrevocable()
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (irrevocable()) return;
//-----------------------------------------------------------------------
// in order to make a tx irrevocable, no other irrevocable txs can be
@@ -142,7 +145,7 @@
while (true)
{
{
- synchro::lock_guard<Mutex> lock_m(*inflight_lock());
+ synchro::lock_guard<Mutex> lock_m(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
if (!irrevocableTxInFlight())
{
@@ -160,6 +163,7 @@
//--------------------------------------------------------------------------
inline void transaction::make_isolated()
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (isolated()) return;
//using namespace std;
@@ -177,8 +181,8 @@
}
{
- synchro::lock_guard<Mutex> lock_g(*general_lock());
- synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lock_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
if (!irrevocableTxInFlight() && canAbortAllInFlightTxs())
{
@@ -197,6 +201,7 @@
//--------------------------------------------------------------------------
inline bool transaction::irrevocable() const
{
+BOOST_STM_TRANSACTION_INVARIANT;
//~ BOOST_STM_INFO << "tx_type="<<tx_type()<<"@"<<const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
switch (tx_type())
{
@@ -206,7 +211,7 @@
default:
BOOST_STM_ERROR << "tx_type="<<tx_type()<<"@"<<const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
BOOST_ASSERT(false&&"tx type not found");
- return false;
+ return false;
}
}
@@ -214,6 +219,7 @@
//--------------------------------------------------------------------------
inline bool transaction::isolated() const
{
+BOOST_STM_TRANSACTION_INVARIANT;
//~ BOOST_STM_INFO << "tx_type="<<tx_type()<<"@"<< const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
switch (tx_type())
{
@@ -223,20 +229,7 @@
default:
BOOST_STM_ERROR << "tx_type="<<tx_type()<<"@"<<const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
BOOST_ASSERT(false&&"tx type not found");
- return false;
- }
-}
-
-inline void transaction::assert_tx_type() const
-{
- //~ BOOST_STM_INFO << "tx_type="<<tx_type()<<"@"<<const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
- switch (tx_type())
- {
- case eNormalTx: return ;
- case eIrrevocableTx: return ;
- case eIrrevocableAndIsolatedTx: return ;
- default:
- BOOST_STM_ERROR << "tx_type="<<tx_type()<<"@"<<const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
+ return false;
}
}
@@ -249,6 +242,7 @@
//-----------------------------------------------------------------------------
inline void transaction::commit_deferred_update_tx()
{
+BOOST_STM_TRANSACTION_INVARIANT;
// ensure this method is isolated
if (!this->irrevocable()) throw invalid_operation("cannot commit deferred tx: not isolated");
@@ -263,8 +257,8 @@
}
#endif
- synchro::lock_guard<Mutex> lock_g(*general_lock());
- synchro::lock_guard<Mutex> lock_m(*mutex());
+ synchro::lock_guard<Mutex> lock_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lock_m(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
//--------------------------------------------------------------------------
// this is a very important and subtle optimization. if the transaction is
@@ -277,7 +271,7 @@
}
else
{
- synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
//-----------------------------------------------------------------------
// commit writes, clear new and deletes
@@ -300,6 +294,7 @@
//-----------------------------------------------------------------------------
inline void transaction::lock_tx()
{
+BOOST_STM_TRANSACTION_INVARIANT;
while (!synchro::try_lock(*mutex()))
{
SLEEP(1);
@@ -312,7 +307,8 @@
//-----------------------------------------------------------------------------
inline void transaction::unlock_tx()
{
- synchro::unlock(*mutex());
+BOOST_STM_TRANSACTION_INVARIANT;
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
//hasMutex_ = 0;
}
@@ -320,14 +316,15 @@
//--------------------------------------------------------------------------
inline void transaction::lock_all_mutexes_but_this(thread_id_t threadId)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
#ifdef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
for (tss_context_map_type::iterator i = tss_context_map_.begin();
i != tss_context_map_.end(); ++i)
{
BOOST_ASSERT(i->secondi!=0);
-
+
if (i->first == threadId) continue;
- synchro::lock(i->second->mutex_);
+ synchro::lock(i->second->mutex_ BOOST_STM_CALL_CONTEXT("mutex")); // INSTANCE
}
#else
for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
@@ -335,8 +332,8 @@
{
if (i->first == threadId) continue;
BOOST_ASSERT(i->second!=0);
-
- synchro::lock(*(i->second));
+
+ synchro::lock(*(i->second) BOOST_STM_CALL_CONTEXT("mutex"));
}
#endif
}
@@ -344,12 +341,13 @@
//--------------------------------------------------------------------------
inline void transaction::unlock_all_mutexes_but_this(thread_id_t threadId)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
#ifdef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
for (tss_context_map_type::iterator i = tss_context_map_.begin();
i != tss_context_map_.end(); ++i)
{
if (i->first == threadId) continue;
- synchro::unlock(i->second->mutex_);
+ synchro::unlock(i->second->mutex_ BOOST_STM_CALL_CONTEXT("mutex"));
}
#else
for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
@@ -358,8 +356,8 @@
if (i->first == threadId) continue;
BOOST_ASSERT(i->second!=0);
-
- synchro::unlock(*(i->second));
+
+ synchro::unlock(*(i->second) BOOST_STM_CALL_CONTEXT("mutex"));
}
#endif
}
@@ -368,21 +366,22 @@
//--------------------------------------------------------------------------
inline void transaction::lock_all_mutexes()
{
+BOOST_STM_TRANSACTION_INVARIANT;
#ifdef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
for (tss_context_map_type::iterator i = tss_context_map_.begin();
i != tss_context_map_.end(); ++i)
{
BOOST_ASSERT(i->second!=0);
-
- synchro::lock(i->second->mutex_);
+
+ synchro::lock(i->second->mutex_ BOOST_STM_CALL_CONTEXT("mutex"));
}
#else
for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
i != threadMutexes_.end(); ++i)
{
BOOST_ASSERT(i->second!=0);
-
- synchro::lock(*(i->second));
+
+ synchro::lock(*(i->second) BOOST_STM_CALL_CONTEXT("mutex"));
}
#endif
//hasMutex_ = 1;
@@ -396,19 +395,20 @@
//-----------------------------------------------------------------------------
inline void transaction::unlock_all_mutexes()
{
+BOOST_STM_TRANSACTION_INVARIANT;
#ifdef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
for (tss_context_map_type::iterator i = tss_context_map_.begin();
i != tss_context_map_.end(); ++i)
{
BOOST_ASSERT(i->second!=0);
- synchro::unlock(i->second->mutex_);
+ synchro::unlock(i->second->mutex_ BOOST_STM_CALL_CONTEXT("mutex"));
}
#else
for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
i != threadMutexes_.end(); ++i)
{
BOOST_ASSERT(i->second!=0);
- synchro::unlock(*(i->second));
+ synchro::unlock(*(i->second) BOOST_STM_CALL_CONTEXT("mutex"));
}
#endif
//hasMutex_ = 0;
@@ -427,39 +427,36 @@
//--------------------------------------------------------------------------
inline transaction::transaction() :
threadId_(this_thread::get_id()),
- //transactionMutexLocker_(),
-#ifndef BOOST_STM_USE_STACK
- parent_(current_transaction()),
-#else
- nested_((current_transaction()!=0));
-#endif
+ //~ transaction_tss_storage_ref_(*transaction_tss_storage_),
+
+
auto_general_lock_(*general_lock()),
#if USE_SINGLE_THREAD_CONTEXT_MAP
////////////////////////////////////////
// BUG possible core dump if find doesn't suceed
- context_(*tss_context_map_.find(threadId_)->second),
+ BOOST_STM_ASSERT_VAR_INIT(context_,*tss_context_map_.find(threadId_)->second),
#ifdef BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
#ifndef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
- write_list_ref_(&context_.writeMem),
+ BOOST_STM_ASSERT_VAR_INIT(write_list_ref_,&context_.writeMem),
bloomRef_(&context_.bloom),
wbloomRef_(&context_.wbloom),
newMemoryListRef_(&context_.newMem),
deletedMemoryListRef_(&context_.delMem),
- txTypeRef_(&context_.txType),
+ BOOST_STM_ASSERT_VAR_INIT(txTypeRef_,&context_.txType),
#ifdef USING_SHARED_FORCED_TO_ABORT
forcedToAbortRef_(&context_.abort),
#else
forcedToAbortRef_(false),
#endif
#else
- write_list_ref_(&context_.tx_.writeMem),
+ BOOST_STM_ASSERT_VAR_INIT(write_list_ref_,&context_.tx_.writeMem),
bloomRef_(&context_.tx_.bloom),
wbloomRef_(&context_.tx_.wbloom),
newMemoryListRef_(&context_.tx_.newMem),
deletedMemoryListRef_(&context_.tx_.delMem),
- txTypeRef_(&context_.tx_.txType),
+ BOOST_STM_ASSERT_VAR_INIT(txTypeRef_,&context_.tx_.txType),
#ifdef USING_SHARED_FORCED_TO_ABORT
forcedToAbortRef_(&context_.tx_.abort),
#else
@@ -482,7 +479,7 @@
// BUG possible core dump if find doesn't suceed
obtainedLocksRef_(*threadObtainedLocks_.find(threadId_)->second),
// BUG possible core dump if find doesn't suceed
- currentlyLockedLocksRef_(*threadCurrentlyLockedLocks_.find(threadId_)->second),
+ BOOST_STM_ASSERT_VAR_INIT(currentlyLockedLocksRef_,*threadCurrentlyLockedLocks_.find(threadId_)->second),
#endif
#endif
////////////////////////////////////////
@@ -492,7 +489,7 @@
// BUG possible core dump if find doesn't suceed
readListRef_(*threadReadLists_.find(threadId_)->second),
#endif
- write_list_ref_(threadWriteLists_.find(threadId_)->second),
+ BOOST_STM_ASSERT_VAR_INIT(write_list_ref_,threadWriteLists_.find(threadId_)->second),
bloomRef_(threadBloomFilterLists_.find(threadId_)->second),
#if PERFORMING_WRITE_BLOOM
wbloomRef_(threadWBloomFilterLists_.find(threadId_)->second),
@@ -500,7 +497,7 @@
#endif
newMemoryListRef_(threadNewMemoryLists_.find(threadId_)->second),
deletedMemoryListRef_(threadDeletedMemoryLists_.find(threadId_)->second),
- txTypeRef_(threadTxTypeLists_.find(threadId_)->second),
+ BOOST_STM_ASSERT_VAR_INIT(txTypeRef_,threadTxTypeLists_.find(threadId_)->second),
#ifdef USING_SHARED_FORCED_TO_ABORT
forcedToAbortRef_(threadForcedToAbortLists_.find(threadId_)->second),
#else
@@ -520,21 +517,28 @@
#endif
// BUG possible core dump if find doesn't suceed
obtainedLocksRef_(*threadObtainedLocks_.find(threadId_)->second),
- currentlyLockedLocksRef_(*threadCurrentlyLockedLocks_.find(threadId_)->second),
+ BOOST_STM_ASSERT_VAR_INIT(currentlyLockedLocksRef_,*threadCurrentlyLockedLocks_.find(threadId_)->second),
#endif
////////////////////////////////////////
#endif
- transaction_tss_storage_ref_(*transaction_tss_storage_),
//hasMutex_(0),
priority_(0),
state_(e_no_state),
reads_(0),
- startTime_(time(0))
+ startTime_(time(0)),
+#ifndef BOOST_STM_USE_STACK
+ BOOST_STM_ASSERT_VAR_INIT(parent_,stm::current_transaction()),
+#else
+ //~ nested_((stm::current_transaction()!=0));
+ BOOST_STM_ASSERT_VAR_INIT(nested_,(transaction_tss_storage_->transactions_.top()!=0)),
+#endif
+ assert_end_flag_(0xffffffff)
{
-#ifdef BOOST_STM_USE_STACK
- nested_=(current_transaction()!=0);
-#endif
auto_general_lock_.unlock();
+ {
+ boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO transaction" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
if (direct_updating()) doIntervalDeletions();
#if PERFORMING_LATM
while (blocked()) { SLEEP(10) ; }
@@ -548,6 +552,7 @@
//--------------------------------------------------------------------------
inline void transaction::begin()
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (e_in_flight == state_) return;
#if PERFORMING_LATM
@@ -561,6 +566,7 @@
//--------------------------------------------------------------------------
inline std::string transaction::outputBlockedThreadsAndLockedLocks()
{
+BOOST_STM_TRANSACTION_INVARIANT;
using namespace std;
ostringstream o;
@@ -606,8 +612,7 @@
//--------------------------------------------------------------------------
inline bool transaction::restart()
{
- //~ BOOST_STM_INFO<<std::endl;
- //~ assert_tx_type();
+BOOST_STM_TRANSACTION_INVARIANT;
//~ BOOST_STM_INFO<<std::endl;
if (e_in_flight == state_) lock_and_abort();
//~ BOOST_STM_INFO<<std::endl;
@@ -624,8 +629,8 @@
#ifdef LOGGING_BLOCKS
if (++iterations > 100)
{
- synchro::lock_guard<Mutex> autolock_l(*latm_lock());
- synchro::lock_guard<Mutex> autolock_g(*general_lock());
+ synchro::lock_guard<Mutex> autolock_l(*latm_lock() BOOST_STM_CALL_CONTEXT("latm_lock"));
+ synchro::lock_guard<Mutex> autolock_g(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
//unblock_threads_if_locks_are_empty();
logFile_ << outputBlockedThreadsAndLockedLocks().c_str();
SLEEP(10000);
@@ -644,7 +649,8 @@
#if PERFORMING_COMPOSITION
#ifdef USING_SHARED_FORCED_TO_ABORT
{
- synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
+BOOST_STM_TRANSACTION_INVARIANT;
//~ BOOST_STM_INFO<<std::endl;
if (!otherInFlightTransactionsOfSameThreadNotIncludingThis(this))
{
@@ -660,10 +666,11 @@
#endif
#endif
- //~ BOOST_STM_INFO<<std::endl;
- //~ assert_tx_type();
+ {BOOST_STM_TRANSACTION_INVARIANT;
+
//~ BOOST_STM_INFO<<std::endl;
put_tx_inflight();
+ }
//~ BOOST_STM_INFO<<std::endl;
#if 0
@@ -684,6 +691,7 @@
//--------------------------------------------------------------------------
inline bool transaction::can_go_inflight()
{
+BOOST_STM_TRANSACTION_INVARIANT;
// if we're doing full lock protection, allow transactions
// to start only if no locks are obtained or the only lock that
// is obtained is on this_thread::get_id()
@@ -727,15 +735,14 @@
//--------------------------------------------------------------------------
inline void transaction::put_tx_inflight()
{
- //~ BOOST_STM_INFO<<std::endl;
- //~ assert_tx_type();
+BOOST_STM_TRANSACTION_INVARIANT;
//~ BOOST_STM_INFO<<std::endl;
#if PERFORMING_LATM
while (true)
{
//~ BOOST_STM_INFO<<std::endl;
{
- synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
//~ BOOST_STM_INFO<<std::endl;
bool b1=latm::instance().can_go_inflight();
@@ -745,6 +752,8 @@
if (b1 && b2)
{
//~ BOOST_STM_INFO<<std::endl;
+BOOST_STM_TRANSACTION_INVARIANT;
+
in_flight_transactions().insert(this);
state_ = e_in_flight;
break;
@@ -755,36 +764,41 @@
SLEEP(10);
}
#else
- synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ synchro::lock_guard<Mutex> lock_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
//~ BOOST_STM_INFO<<std::endl;
+ {BOOST_STM_TRANSACTION_INVARIANT;
+
in_flight_transactions().insert(this);
+ }
//~ BOOST_STM_INFO<<std::endl;
state_ = e_in_flight;
#endif
//~ BOOST_STM_INFO<<std::endl;
- //~ assert_tx_type();
- //~ BOOST_STM_INFO<<std::endl;
}
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
inline transaction::~transaction()
{
- //~ BOOST_STM_INFO<<std::endl;
- //~ assert_tx_type();
- //~ BOOST_STM_INFO<<std::endl;
+ BOOST_STM_CALL_CONTEXT_DCL_INST(this);
+ {
+ boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO ~transaction" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
+ //~ BOOST_STM_INFO<<std::endl;
// if we're not an inflight transaction - bail
if (state_ != e_in_flight)
{
//~ BOOST_STM_INFO<<std::endl;
//if (hasLock()) unlock_tx();
+ transactions().pop();
return;
}
//~ BOOST_STM_INFO<<std::endl;
//if (!hasLock())
{
- synchro::lock_guard<Mutex> lock(*mutex());
+ synchro::lock_guard<Mutex> lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
//~ BOOST_STM_INFO<<std::endl;
abort();
//~ BOOST_STM_INFO<<std::endl;
@@ -807,6 +821,7 @@
//--------------------------------------------------------------------------
inline void transaction::no_throw_end()
{
+BOOST_STM_TRANSACTION_INVARIANT;
try { end(); }
catch (...) {}
}
@@ -815,11 +830,13 @@
//--------------------------------------------------------------------------
inline void transaction::end()
{
+BOOST_STM_TRANSACTION_INVARIANT;
// in case this is called multiple times
if (!in_flight()) return;
if (direct_updating())
{
+BOOST_STM_TRANSACTION_INVARIANT;
#if PERFORMING_VALIDATION
validating_direct_end_transaction();
#else
@@ -828,6 +845,7 @@
}
else
{
+BOOST_STM_TRANSACTION_INVARIANT;
#if PERFORMING_VALIDATION
validating_deferred_end_transaction();
#else
@@ -849,15 +867,16 @@
//-----------------------------------------------------------------------------
inline void transaction::lock_and_abort()
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (direct_updating())
{
- synchro::lock_guard_if<Mutex> lock_g(*general_lock(), isWriting());
- synchro::lock_guard<Mutex> lock_m(*mutex());
+ synchro::lock_guard_if<Mutex> lock_g(*general_lock(), isWriting() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock_guard<Mutex> lock_m(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
direct_abort();
}
else
{
- synchro::lock_guard<Mutex> lock_m(*mutex());
+ synchro::lock_guard<Mutex> lock_m(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
deferred_abort();
}
}
@@ -867,6 +886,7 @@
//-----------------------------------------------------------------------------
inline void transaction::invalidating_direct_end_transaction()
{
+BOOST_STM_TRANSACTION_INVARIANT;
//--------------------------------------------------------------------------
// this is an optimization to check forced to abort before obtaining the
// transaction mutex, so if we do need to abort we do it now
@@ -878,10 +898,10 @@
("aborting committing transaction due to contention manager priority inversion");
}
- synchro::lock(*general_lock());
+ synchro::lock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
//synchro::unique_lock<Mutex> lk_g(*general_lock());
//lock_tx();
- synchro::lock(*mutex());
+ synchro::lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
//synchro::lock_guard<Mutex> lk_m(*mutex());
// direct_abort_if_not_commited_and_not_handoff(this);
@@ -899,15 +919,15 @@
// so unlock it so we can reduce contention
//-----------------------------------------------------------------------
bool wasWriting = isWriting() ? true : false;
- if (!wasWriting) synchro::unlock(*general_lock()); // TBR
+ if (!wasWriting) synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock")); // TBR
//if (!wasWriting) lk_g.unlock();
direct_abort(); // TBR
- synchro::unlock(*mutex()); // TBR
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex")); // TBR
//-----------------------------------------------------------------------
// if this tx was writing, unlock the transaction mutex now
//-----------------------------------------------------------------------
- if (wasWriting) synchro::unlock(*general_lock());// TBR
+ if (wasWriting) synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));// TBR
throw aborted_transaction_exception
("aborting committing transaction due to contention manager priority inversion");
}
@@ -915,16 +935,19 @@
lock_all_mutexes_but_this(threadId_);// TBR
// all_mutexes_but_this all_but_this(this, threadId_);
- synchro::lock(*inflight_lock());// TBR
+ synchro::lock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));// TBR
//synchro::lock_guard<Mutex> lk_i(*inflight_lock());
+ {BOOST_STM_TRANSACTION_INVARIANT;
+ boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
in_flight_transactions().erase(this);
-
+ }
if (other_in_flight_same_thread_transactions())
{
state_ = e_hand_off;
unlock_all_mutexes();// TBR
- synchro::unlock(*general_lock());// TBR
- synchro::unlock(*inflight_lock());// TBR
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));// TBR
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));// TBR
bookkeeping_.inc_handoffs();
}
else
@@ -935,8 +958,8 @@
if (e_committed == state_)
{
unlock_all_mutexes();
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
} else {
BOOST_STM_ERROR<<std::endl;
std::cout << "invalidating_direct_end_transaction e_committed != state_" << std::endl;
@@ -949,6 +972,7 @@
//-----------------------------------------------------------------------------
inline void transaction::invalidating_deferred_end_transaction()
{
+BOOST_STM_TRANSACTION_INVARIANT;
//--------------------------------------------------------------------------
// this is an optimization to check forced to abort before obtaining the
// transaction mutex, so if we do need to abort we do it now
@@ -956,7 +980,9 @@
#ifndef DELAY_INVALIDATION_DOOMED_TXS_UNTIL_COMMIT
if (forced_to_abort())
{
- deferred_abort(true);
+BOOST_STM_TRANSACTION_INVARIANT;
+ // BUG inversion
+ deferred_abort();
throw aborted_transaction_exception
("aborting committing transaction due to contention manager priority inversion");
}
@@ -970,8 +996,12 @@
if (is_only_reading())
{
{
- synchro::unique_lock<Mutex> lk_i(*inflight_lock());
+ synchro::unique_lock<Mutex> lk_i(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
+ BOOST_STM_TRANSACTION_INVARIANT;
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
in_flight_transactions().erase(this);
#if PERFORMING_COMPOSITION
@@ -999,7 +1029,7 @@
}
//while (!synchro::try_lock(*general_lock())) {}
- synchro::lock(*general_lock());
+ synchro::lock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
//synchro::unique_lock<Mutex> lk_g(*general_lock());
@@ -1012,9 +1042,9 @@
//--------------------------------------------------------------------------
if (forced_to_abort())
{
- synchro::unlock(*general_lock()); //TBR
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock")); //TBR
//lk.g.unlock();
- deferred_abort(true);
+ deferred_abort();
throw aborted_transaction_exception
("aborting committing transaction due to contention manager priority inversion");
}
@@ -1035,18 +1065,22 @@
//-----------------------------------------------------------------------
lock_all_mutexes(); //TBR
//all_mutexes lk_all(this);
- synchro::lock(*inflight_lock());
+ synchro::lock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
//synchro::unique_lock<Mutex> lk_i(*inflight_lock());
#if PERFORMING_COMPOSITION
// BUG
if (other_in_flight_same_thread_transactions())
{
+ BOOST_STM_TRANSACTION_INVARIANT;
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
in_flight_transactions().erase(this);
state_ = e_hand_off;
unlock_all_mutexes();//TBR
- synchro::unlock(*general_lock());//TBR
- synchro::unlock(*inflight_lock());//TBR
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));//TBR
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));//TBR
bookkeeping_.inc_handoffs();
}
else
@@ -1066,8 +1100,9 @@
//-----------------------------------------------------------------------------
inline void transaction::validating_direct_end_transaction()
{
- synchro::lock(*general_lock());
- synchro::lock(*mutex());
+BOOST_STM_TRANSACTION_INVARIANT;
+ synchro::lock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
//--------------------------------------------------------------------------
// can only be called after above transactionMutex_ is called
@@ -1076,8 +1111,8 @@
{
abort();
//bookkeeping_.inc_abort_perm_denied(threadId_);
- synchro::unlock(*mutex());
- synchro::unlock(*general_lock());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
throw aborted_transaction_exception
("aborting commit due to CM priority");
}
@@ -1096,28 +1131,33 @@
// so unlock it so we can reduce contention
//-----------------------------------------------------------------------
bool wasWriting = isWriting() ? true : false;
- if (!wasWriting) synchro::unlock(*general_lock());
+ if (!wasWriting) synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
direct_abort();
- synchro::unlock(*general_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
//-----------------------------------------------------------------------
// if this tx was writing, unlock the transaction mutex now
//-----------------------------------------------------------------------
- if (wasWriting) synchro::unlock(*general_lock());
+ if (wasWriting) synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
throw aborted_transaction_exception
("aborting committing transaction due to contention manager priority inversion");
}
lock_all_mutexes_but_this(threadId_);
- synchro::lock(*inflight_lock());
+ synchro::lock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
+ {BOOST_STM_TRANSACTION_INVARIANT;
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
in_flight_transactions().erase(this);
+ }
if (other_in_flight_same_thread_transactions())
{
state_ = e_hand_off;
unlock_all_mutexes();
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
bookkeeping_.inc_handoffs();
}
else
@@ -1128,8 +1168,8 @@
if (e_committed == state_)
{
unlock_all_mutexes();
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
}
}
}
@@ -1139,9 +1179,10 @@
//-----------------------------------------------------------------------------
inline void transaction::validating_deferred_end_transaction()
{
- synchro::lock(*general_lock());
- synchro::lock(*inflight_lock());
- synchro::lock(*mutex());
+BOOST_STM_TRANSACTION_INVARIANT;
+ synchro::lock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
+ synchro::lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
//--------------------------------------------------------------------------
// can only be called after above transactionMutex_ is called
@@ -1149,15 +1190,15 @@
if (cm_abort_before_commit(*this))
{
//bookkeeping_.inc_abort_perm_denied(threadId_);
- synchro::unlock(*inflight_lock());
- synchro::unlock(*general_lock());
- synchro::unlock(*mutex());
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw aborted_transaction_exception
("aborting commit due to CM priority");
}
// unlock this - we only needed it to check abort_before_commit()
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
clock_t ms = clock();
@@ -1170,9 +1211,9 @@
//--------------------------------------------------------------------------
if (forced_to_abort())
{
- synchro::unlock(*general_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
deferred_abort();
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw aborted_transaction_exception
("aborting committing transaction due to contention manager priority inversion");
}
@@ -1186,7 +1227,9 @@
//--------------------------------------------------------------------------
if (is_only_reading())
{
- synchro::lock(*inflight_lock());
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
in_flight_transactions().erase(this);
if (other_in_flight_same_thread_transactions())
@@ -1204,15 +1247,15 @@
state_ = e_committed;
}
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
bookkeeping_.inc_commits();
#ifndef DISABLE_READ_SETS
bookkeeping_.pushBackSizeOfReadSetWhenCommitting(readList().size());
#endif
bookkeeping_.inc_commit_time_ms(clock() - ms);
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
}
//-----------------------------------------------------------------------
@@ -1230,15 +1273,20 @@
//-----------------------------------------------------------------------
lock_all_mutexes_but_this(threadId_);
- synchro::lock(*inflight_lock());
- in_flight_transactions().erase(this);
+ synchro::lock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
+ {BOOST_STM_TRANSACTION_INVARIANT;
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
+ in_flight_transactions().erase(this);
+ }
if (other_in_flight_same_thread_transactions())
{
state_ = e_hand_off;
unlock_all_mutexes();
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
bookkeeping_.inc_handoffs();
}
else
@@ -1252,9 +1300,9 @@
if (e_committed == state_)
{
//unlock_tx();
- synchro::unlock(*mutex());
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
}
}
}
@@ -1265,6 +1313,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::forceOtherInFlightTransactionsWritingThisWriteMemoryToAbort()
{
+BOOST_STM_TRANSACTION_INVARIANT;
#ifndef ALWAYS_ALLOW_ABORT
std::list<transaction*> aborted;
#endif
@@ -1278,7 +1327,7 @@
j != in_flight_transactions().end();)
{
BOOST_ASSERT(*j!=0);
- //~ (*j)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*j);
transaction *t = *j;
// if we're already aborting for this transaction, skip it
@@ -1305,7 +1354,13 @@
next = j;
++next;
+ {BOOST_STM_TRANSACTION_INVARIANT;
+
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << j<< " " << j->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
in_flight_transactions().erase(j);
+ }
j = next;
#else
@@ -1337,6 +1392,11 @@
{
BOOST_ASSERT(k!=0);
(*k)->force_to_abort();
+ BOOST_STM_TRANSACTION_INVARIANT;
+
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << *k<< " " << (*k)->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
in_flight_transactions().erase(*k);
}
#endif
@@ -1353,6 +1413,7 @@
inline void transaction::direct_abort
(bool const &alreadyRemovedFromInFlight) throw()
{
+BOOST_STM_TRANSACTION_INVARIANT;
#if LOGGING_COMMITS_AND_ABORTS
bookkeeping_.pushBackSizeOfReadSetWhenAborting(readList().size());
@@ -1376,8 +1437,13 @@
#endif
if (!alreadyRemovedFromInFlight)
{
- synchro::lock(*inflight_lock());
+ synchro::lock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
// if I'm the last transaction of this thread, reset abort to false
+ BOOST_STM_TRANSACTION_INVARIANT;
+
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
in_flight_transactions().erase(this);
}
@@ -1391,7 +1457,7 @@
#endif
if (!alreadyRemovedFromInFlight)
{
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
}
}
catch (...)
@@ -1405,6 +1471,7 @@
inline void transaction::deferred_abort
(bool const &alreadyRemovedFromInFlight) throw()
{
+BOOST_STM_TRANSACTION_INVARIANT;
#if LOGGING_COMMITS_AND_ABORTS
bookkeeping_.pushBackSizeOfReadSetWhenAborting(readList().size());
bookkeeping_.pushBackSizeOfWriteSetWhenAborting(writeList().size());
@@ -1412,13 +1479,17 @@
state_ = e_aborted;
- deferredAbortWriteList();
+{BOOST_STM_TRANSACTION_INVARIANT; deferredAbortWriteList();}
#ifndef DISABLE_READ_SETS
- deferredAbortReadList();
+{BOOST_STM_TRANSACTION_INVARIANT; deferredAbortReadList();}
#endif
+{BOOST_STM_TRANSACTION_INVARIANT;
deferredAbortTransactionDeletedMemory();
+}
+{BOOST_STM_TRANSACTION_INVARIANT;
deferredAbortTransactionNewMemory();
+}
bloom().clear();
#if PERFORMING_WRITE_BLOOM
@@ -1426,9 +1497,12 @@
#endif
if (!alreadyRemovedFromInFlight)
- {
- synchro::lock(*inflight_lock());
+ {BOOST_STM_TRANSACTION_INVARIANT;
+ synchro::lock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
// if I'm the last transaction of this thread, reset abort to false
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
in_flight_transactions().erase(this);
#ifdef USING_SHARED_FORCED_TO_ABORT
@@ -1440,7 +1514,7 @@
unforce_to_abort();
#endif
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
}
else {
unforce_to_abort();
@@ -1450,6 +1524,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::invalidating_direct_commit()
{
+BOOST_STM_TRANSACTION_INVARIANT;
//--------------------------------------------------------------------------
// transactionMutex must be obtained before calling commit
//--------------------------------------------------------------------------
@@ -1490,11 +1565,11 @@
catch (aborted_transaction_exception&)
{
unlock_all_mutexes_but_this(threadId_);
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
direct_abort();
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw;
}
@@ -1504,11 +1579,11 @@
catch (...)
{
unlock_all_mutexes_but_this(threadId_);
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
direct_abort();
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw;
}
@@ -1517,6 +1592,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::invalidating_deferred_commit()
{
+BOOST_STM_TRANSACTION_INVARIANT;
//--------------------------------------------------------------------------
// transactionMutex must be obtained before calling commit
//--------------------------------------------------------------------------
@@ -1566,8 +1642,8 @@
++stalling_;
clock_t local_clock = global_clock();
- synchro::unlock(*inflight_lock());
- synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
unlock_all_mutexes();
for (;;)
@@ -1584,8 +1660,8 @@
throw aborted_transaction_exception_no_unlocks();
}
- synchro::lock(*general_lock());
- synchro::lock(*inflight_lock());
+ synchro::lock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::lock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
// if our stalling on tx is gone, continue
if (in_flight_transactions().end() == in_flight_transactions().find(stallingOn))
@@ -1597,8 +1673,8 @@
break;
}
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
}
lock_all_mutexes();
@@ -1620,9 +1696,12 @@
//BUG
//~ in_flight_transactions().erase(this);
//~ synchro::unlock(*inflight_lock());
- synchro::unlock(*inflight_lock());
+ {boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << this << " " << this->parent() << " " << this_thread::get_id() << " ****INFO erase" << __FILE__ << "[" << __LINE__ << "]" << BOOST_CURRENT_FUNCTION << std::endl;
+ }
in_flight_transactions().erase(this);
- synchro::unlock(*general_lock());
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
deferredCommitWriteState();
@@ -1669,10 +1748,10 @@
catch (aborted_transaction_exception&)
{
unlock_all_mutexes_but_this(threadId_);
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
deferred_abort();
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw;
}
@@ -1682,10 +1761,10 @@
catch (...)
{
unlock_all_mutexes_but_this(threadId_);
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
deferred_abort();
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw;
}
@@ -1696,6 +1775,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::validating_direct_commit()
{
+BOOST_STM_TRANSACTION_INVARIANT;
throw not_implemented("not implemented yet: validating_direct_commit";
@@ -1755,11 +1835,11 @@
catch (aborted_transaction_exception&)
{
unlock_all_mutexes_but_this(threadId_);
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
direct_abort();
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw;
}
@@ -1769,11 +1849,11 @@
catch (...)
{
unlock_all_mutexes_but_this(threadId_);
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
direct_abort();
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw;
}
@@ -1784,6 +1864,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::validating_deferred_commit()
{
+BOOST_STM_TRANSACTION_INVARIANT;
//--------------------------------------------------------------------------
// transactionMutex must be obtained before calling commit
//--------------------------------------------------------------------------
@@ -1864,10 +1945,10 @@
catch (aborted_transaction_exception&)
{
unlock_all_mutexes_but_this(threadId_);
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
deferred_abort();
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw;
}
@@ -1877,10 +1958,10 @@
catch (...)
{
unlock_all_mutexes_but_this(threadId_);
- synchro::unlock(*general_lock());
- synchro::unlock(*inflight_lock());
+ synchro::unlock(*general_lock() BOOST_STM_CALL_CONTEXT("general_lock"));
+ synchro::unlock(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
deferred_abort();
- synchro::unlock(*mutex());
+ synchro::unlock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
throw;
}
@@ -1890,9 +1971,10 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::unlockAllLockedThreads(LockedTransactionContainer &l)
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (LockedTransactionContainer::iterator i = l.begin(); i != l.end(); ++i) {
BOOST_ASSERT(*i!=0);
-
+
(*i)->unlock_tx();
}
}
@@ -1900,6 +1982,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::directAbortWriteList()
{
+BOOST_STM_TRANSACTION_INVARIANT;
//--------------------------------------------------------------------------
// copy the newObject into the oldObject, updating the real data back to
// what it was before we changed it
@@ -1934,6 +2017,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::directAbortTransactionDeletedMemory() throw()
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (MemoryContainerList::iterator j = deletedMemoryList().begin();
j != deletedMemoryList().end(); ++j)
{
@@ -1946,18 +2030,22 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::deferredAbortWriteList() throw()
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (WriteContainer::iterator i = writeList().begin(); writeList().end() != i; ++i)
{
- cache_release(i->second); // delete all the temporary memory
+ //BUGdelete
+ cache_release(i->second); // delete all the temporary memory
}
+ //BUGdelete
writeList().clear();
}
//----------------------------------------------------------------------------
inline clock_t transaction::earliest_start_time_of_inflight_txes()
{
- synchro::lock_guard<Mutex> a(*inflight_lock());
+BOOST_STM_TRANSACTION_INVARIANT;
+ synchro::lock_guard<Mutex> a(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
clock_t secs = 0xffffffff;
@@ -1965,7 +2053,7 @@
j != in_flight_transactions().end(); ++j)
{
BOOST_ASSERT(*j!=0);
- //~ (*j)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*j);
transaction *t = *j;
//-----------------------------------------------------------------------
// since this is called while direct_writes are occurring, the transaction
@@ -1980,11 +2068,12 @@
//----------------------------------------------------------------------------
inline void transaction::doIntervalDeletions()
{
+BOOST_STM_TRANSACTION_INVARIANT;
using namespace boost::stm;
clock_t earliestInFlightTx = earliest_start_time_of_inflight_txes();
- synchro::lock_guard<Mutex> a(deletionBufferMutex_);
+ synchro::lock_guard<Mutex> a(deletionBufferMutex_ BOOST_STM_CALL_CONTEXT("deletionBufferMutex_"));
for (DeletionBuffer::iterator i = deletionBuffer_.begin(); i != deletionBuffer_.end();)
{
@@ -2008,11 +2097,12 @@
//----------------------------------------------------------------------------
inline void transaction::directCommitTransactionDeletedMemory() throw()
{
+BOOST_STM_TRANSACTION_INVARIANT;
using namespace boost::stm;
if (!deletedMemoryList().empty())
{
- synchro::lock_guard<Mutex> a(deletionBufferMutex_);
+ synchro::lock_guard<Mutex> a(deletionBufferMutex_ BOOST_STM_CALL_CONTEXT("deletionBufferMutex_"));
deletionBuffer_.insert( std::pair<clock_t, MemoryContainerList>
(time(0), deletedMemoryList()) );
deletedMemoryList().clear();
@@ -2022,6 +2112,7 @@
//----------------------------------------------------------------------------
inline void transaction::deferredCommitTransactionDeletedMemory() throw()
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (MemoryContainerList::iterator i = deletedMemoryList().begin();
i != deletedMemoryList().end(); ++i)
{
@@ -2035,20 +2126,26 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::deferredAbortTransactionNewMemory() throw()
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (MemoryContainerList::iterator i = newMemoryList().begin(); i != newMemoryList().end(); ++i)
{
- detail::release(*i);
+ BOOST_ASSERT(*i);
+ //BUGdelete
+ detail::release(*i);
//delete *i;
}
+ //BUGdelete
newMemoryList().clear();
}
////////////////////////////////////////////////////////////////////////////
inline void transaction::deferredCommitTransactionNewMemory()
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (MemoryContainerList::iterator i = newMemoryList().begin(); i != newMemoryList().end(); ++i)
{
+ BOOST_ASSERT(*i);
detail::reset(*i);
}
@@ -2058,6 +2155,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::directCommitWriteState()
{
+BOOST_STM_TRANSACTION_INVARIANT;
// direct commit for writes just deletes the backup and changes global memory
// so its no longer flagged as being transactional
for (WriteContainer::iterator i = writeList().begin(); writeList().end() != i; ++i)
@@ -2088,6 +2186,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::deferredCommitWriteState()
{
+BOOST_STM_TRANSACTION_INVARIANT;
// copy the newObject into the oldObject, updating the real data
for (WriteContainer::iterator i = writeList().begin(); writeList().end() != i; ++i)
{
@@ -2104,7 +2203,7 @@
}
BOOST_ASSERT(i->first!=0);
-
+
if (using_move_semantics()) i->first->move_state(i->second);
else i->first->copy_cache(*i->second);
@@ -2124,11 +2223,12 @@
//----------------------------------------------------------------------------
inline void transaction::verifyReadMemoryIsValidWithGlobalMemory()
{
+BOOST_STM_TRANSACTION_INVARIANT;
// copy the newObject into the oldObject, updating the real data
for (ReadContainer::iterator i = readList().begin(); readList().end() != i; ++i)
{
BOOST_ASSERT(i->first!=0);
-
+
if (i->first->version_ != i->second)
{
bookkeeping_.inc_read_aborts();
@@ -2141,11 +2241,12 @@
//----------------------------------------------------------------------------
inline void transaction::verifyWrittenMemoryIsValidWithGlobalMemory()
{
+BOOST_STM_TRANSACTION_INVARIANT;
// copy the newObject into the oldObject, updating the real data
for (WriteContainer::iterator i = writeList().begin(); writeList().end() != i; ++i)
{
BOOST_ASSERT(i->first!=0);
-
+
if (0 == i->second) continue;
if (i->first->version_ != i->second->version_)
{
@@ -2160,12 +2261,13 @@
////////////////////////////////////////////////////////////////////////////
inline bool transaction::otherInFlightTransactionsWritingThisMemory(base_transaction_object *obj)
{
+BOOST_STM_TRANSACTION_INVARIANT;
// iterate through all the in flight transactions
for (in_flight_trans_cont::iterator j = in_flight_transactions().begin();
j != in_flight_transactions().end(); ++j)
{
BOOST_ASSERT(*j!=0);
- //~ (*j)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*j);
transaction *t = *j;
//-----------------------------------------------------------------------
// since this is called while direct_writes are occurring, the transaction
@@ -2188,6 +2290,7 @@
inline bool transaction::forceOtherInFlightTransactionsAccessingThisWriteMemoryToAbort
(bool allow_stall, transaction* &stallingOn)
{
+BOOST_STM_TRANSACTION_INVARIANT;
static std::list<transaction*> aborted;
//static bool initialized = false;
@@ -2223,7 +2326,7 @@
j != in_flight_transactions().end(); ++j)
{
BOOST_ASSERT(*j!=0);
- //~ (*j)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*j);
transaction *t = *j;
// if we're already aborting for this transaction, skip it
if (t->forced_to_abort()) continue;
@@ -2321,7 +2424,7 @@
k != aborted.end(); ++k)
{
BOOST_ASSERT(*k!=0);
-
+
(*k)->force_to_abort();
}
@@ -2341,6 +2444,7 @@
////////////////////////////////////////////////////////////////////////////
inline void transaction::forceOtherInFlightTransactionsReadingThisWriteMemoryToAbort()
{
+BOOST_STM_TRANSACTION_INVARIANT;
std::list<transaction*> aborted;
// iterate through all the in flight transactions
@@ -2348,7 +2452,7 @@
j != in_flight_transactions().end(); ++j)
{
BOOST_ASSERT(*j!=0);
- //~ (*j)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*j);
transaction *t = *j;
// if we're already aborting for this transaction, skip it
#ifndef DISABLE_READ_SETS
@@ -2399,7 +2503,7 @@
for (std::list<transaction*>::iterator k = aborted.begin(); k != aborted.end(); ++k)
{
BOOST_ASSERT(*k!=0);
-
+
(*k)->force_to_abort();
//bookkeeping_.inc_abort_perm_denied((*k)->threadId_);
}
@@ -2417,11 +2521,12 @@
//-----------------------------------------------------------------------------
inline bool transaction::other_in_flight_same_thread_transactions() const throw()
{
+BOOST_STM_TRANSACTION_INVARIANT;
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
i != in_flight_transactions().end(); ++i)
{
BOOST_ASSERT(*i!=0);
- //~ (*i)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*i);
if (*i == this) continue;
if (*i == 0) continue;
// if this is not our threadId or this thread is not composable, skip it
@@ -2434,11 +2539,12 @@
inline bool transaction::otherInFlightTransactionsOfSameThreadNotIncludingThis(transaction const * const rhs)
{
+BOOST_STM_TRANSACTION_INVARIANT;
//////////////////////////////////////////////////////////////////////
for (in_flight_trans_cont::iterator i = in_flight_transactions().begin(); i != in_flight_transactions().end(); ++i)
{
BOOST_ASSERT(*i!=0);
- //~ (*i)->assert_tx_type();
+ BOOST_STM_TRANSACTION_INVARIANT_VAR(*i);
if (*i == rhs) continue;
// if this is not our threadId or this thread is not composable, skip it
if ((*i)->threadId_ != this->threadId_) continue;
Modified: sandbox/stm/branches/vbe/boost/stm/detail/transactions_stack.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/transactions_stack.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/transactions_stack.hpp 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -41,7 +41,7 @@
#else
transaction* inner_;
std::size_t count_;
- transactions_stack() : inner_(0), count_(0)
+ transactions_stack() : inner_(0), count_(0)
{
// the stack at least one element (0) so we can always call to top, i.e. current transaction is 0
}
@@ -49,7 +49,7 @@
inline void pop();
std::size_t size() {return count_;}
transaction* top() {return inner_;}
-#endif
+#endif
};
Modified: sandbox/stm/branches/vbe/boost/stm/latm/all_in_one_mode.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/latm/all_in_one_mode.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/latm/all_in_one_mode.hpp 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -39,6 +39,7 @@
return "tx_protect";
default:
BOOST_ASSERT(false&& "invalid LATM type");
+ return "";
}
}
void do_full_lock_protection_i() {
@@ -110,9 +111,10 @@
}
void tm_lock_conflict(latm::mutex_type* inLock)
{
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
if (!this->doing_tm_lock_protection()) return;
- synchro::lock_guard<Mutex> lock_l(latmMutex_);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//-------------------------------------------------------------------------
// insert can throw an exception
Modified: sandbox/stm/branches/vbe/boost/stm/latm/base_mode.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/latm/base_mode.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/latm/base_mode.hpp 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -36,7 +36,8 @@
void clear_tm_conflicting_locks()
{
- synchro::lock_guard<Mutex> lock_l(latmMutex_);
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+ synchro::lock_guard<Mutex> lock_l(latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
tmConflictingLocks_.clear();
}
Modified: sandbox/stm/branches/vbe/boost/stm/latm/tm_mode.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/latm/tm_mode.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/latm/tm_mode.hpp 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -26,7 +26,7 @@
class tm_mode : public base_mode<Base> {
public:
~tm_mode() {}
-
+
latm_type const protection() { return eTmConflictingLockLatmProtection; }
std::string const protection_str() {
return "tm_protect";
@@ -73,7 +73,8 @@
}
void tm_lock_conflict(latm::mutex_type* inLock)
{
- synchro::lock_guard<Mutex> lock_l(this->latmMutex_);
+ BOOST_STM_CALL_CONTEXT_DCL_INST(0);
+ synchro::lock_guard<Mutex> lock_l(this->latmMutex_ BOOST_STM_CALL_CONTEXT("latm_lock"));
//-------------------------------------------------------------------------
// insert can throw an exception
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 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -25,6 +25,8 @@
#include <set>
#include <string>
#include <vector>
+#include <boost/synchro/call_context.hpp>
+
//-----------------------------------------------------------------------------
#include <boost/stm/trace.hpp>
#include <boost/synchro/tss.hpp>
@@ -53,9 +55,65 @@
#include <boost/stm/detail/vector_set.hpp>
#include <boost/stm/incomplete_smart_cast.hpp>
-//-----------------------------------------------------------------------------
+
namespace boost { namespace stm {
+#ifdef BOOST_STM_USE_INVARIANT
+template <typename T>
+struct scoped_check_invariant {
+ T const& that_;
+ const char* file;
+ std::size_t line;
+ const char* fct;
+ scoped_check_invariant(T const& ref, const char* f, std::size_t l, const char* function) : that_(ref), file(f), line(l), fct(function) {
+ if (!that_.invariant()) {
+ boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << &that_ << " " << that_.parent() << " " << std::hex << this_thread::get_id() << std::dec << " $$$$$ERROR on constructor " << file << "[" << line << "] " << fct << std::endl;
+ assert(false);
+ } else {
+ boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << &that_ << " " << that_.parent() << " " << std::hex << this_thread::get_id() << std::dec << " $$$$$INFO on constructor " << file << "[" << line << "] " << fct << std::endl;
+ }
+ }
+ ~scoped_check_invariant() {
+ if (!that_.invariant()) {
+ boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << &that_ << " " << that_.parent() << " " << std::hex << this_thread::get_id() << std::dec << " %%%%%ERROR on destructor "<< file << "[" << line << "] " << fct << std::endl;
+ assert(false);
+ } else {
+ boost::lock_guard<boost::mutex> lk(log_mutex);
+ std::cout << &that_ << " " << that_.parent() << " " << std::hex << this_thread::get_id() << std::dec<< " %%%%%%INFO on destructor "<< file << "[" << line << "] " << fct<< std::endl;
+ }
+ }
+};
+
+#define BOOST_STM_SCOPED_INVARIANT_TYPE_VAR(TYPE, VAR) BOOST_STM_CALL_CONTEXT_DCL_INST(VAR); scoped_check_invariant<TYPE> __invariant(*VAR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
+#define BOOST_STM_SCOPED_INVARIANT_TYPE(TYPE) BOOST_STM_SCOPED_INVARIANT_TYPE_VAR(TYPE, this)
+#define BOOST_STM_TRANSACTION_INVARIANT_VAR(VAR) BOOST_STM_SCOPED_INVARIANT_TYPE_VAR(boost::stm::transaction, VAR)
+#define BOOST_STM_TRANSACTION_INVARIANT BOOST_STM_SCOPED_INVARIANT_TYPE(boost::stm::transaction)
+#define BOOST_STM_ASSERT_VAR_INIT(VAR,VALUE) VAR(VALUE), BOOST_JOIN(assert_,VAR)(VAR)
+#define BOOST_STM_ASSERT_VAR_DCL(TYPE,VAR) TYPE VAR; TYPE BOOST_JOIN(assert_,VAR)
+#else
+#define BOOST_STM_TRANSACTION_INVARIANT_VAR(VAR) ((void)0)
+#define BOOST_STM_TRANSACTION_INVARIANT ((void)0)
+#define BOOST_STM_ASSERT_VAR_INIT(VAR,VALUE) VAR(VALUE)
+#define BOOST_STM_ASSERT_VAR_DCL(TYPE,VAR) TYPE VAR
+#endif
+
+
+#define BOOST_STM_RET_IF_FALSE(EXPR) \
+ if (EXPR);else {\
+ boost::lock_guard<boost::mutex> lk(log_mutex); \
+ std::cout << this << " " << this->parent() << " " << std::hex << this_thread::get_id() << std::dec << " ****ERROR " << __FILE__ << "[" << __LINE__ << "]" << std::endl;\
+ return false;\
+ }
+
+// BOOST_STM_ERROR << #EXPR << std::endl;
+
+
+
+//-----------------------------------------------------------------------------
+
namespace detail {
template <int> struct dummy { dummy(int) {} };
}
@@ -110,11 +168,11 @@
typedef std::map<thread_id_t, TxType*> ThreadTxTypeContainer;
typedef std::set<transaction*> TContainer;
-#ifdef BOOST_USE_INFLIGH_TRANSACTION_PTR_SET
+#ifdef BOOST_USE_INFLIGH_TRANSACTION_PTR_SET
typedef std::set<transaction**> in_flight_trans_cont;
-#else
+#else
typedef std::set<transaction*> in_flight_trans_cont;
-#endif
+#endif
typedef std::multimap<clock_t, MemoryContainerList > DeletionBuffer;
@@ -388,13 +446,18 @@
bool is_nested() const
{
+#ifdef BOOST_STM_USE_STACK
+ return nested_;
+#else
return parent_!=0;
+#endif
//~ synchro::lock_guard<Mutex> lock_m(*inflight_lock());
//~ return other_in_flight_same_thread_transactions();
}
bool check_throw_before_restart() const
{
+ BOOST_STM_TRANSACTION_INVARIANT;
// if this transaction is in-flight or it committed, just ignore it
if (in_flight() || committed()) return true;
@@ -404,7 +467,7 @@
// an exception here because restarting the transactions will cause it to
// infinitely fail
//-----------------------------------------------------------------------
- synchro::lock_guard<Mutex> lock_m(*inflight_lock());
+ synchro::lock_guard<Mutex> lock_m(*inflight_lock() BOOST_STM_CALL_CONTEXT("inflight_lock"));
if (other_in_flight_same_thread_transactions())
{
throw aborted_transaction_exception("closed nesting throws");
@@ -422,7 +485,8 @@
template <typename T>
T& find_original(T& in)
{
- //-----------------------------------------------------------------------
+ BOOST_STM_TRANSACTION_INVARIANT;
+ //-----------------------------------------------------------------------
// if transactionThread_ is not invalid it means this is the original, so
// we can return it. Otherwise, we need to search for the original in
// our write set
@@ -558,7 +622,8 @@
template <typename T>
inline T const & read(T const & in)
{
- if (direct_updating())
+BOOST_STM_TRANSACTION_INVARIANT;
+ if (direct_updating())
{
#if PERFORMING_VALIDATION
throw not_implemented("direct updating not implemented for validation yet");
@@ -582,7 +647,8 @@
template <typename T>
inline T& write(T& in)
{
- return write_poly<static_poly>(in);
+BOOST_STM_TRANSACTION_INVARIANT;
+ return write_poly<static_poly>(in);
}
template <typename T> T* write_ptr_dyn(T* in)
@@ -593,6 +659,7 @@
template <typename T>
inline T& write_dyn(T& in)
{
+BOOST_STM_TRANSACTION_INVARIANT;
return write_poly<dyn_poly>(in);
}
@@ -606,6 +673,7 @@
template <typename Poly, typename T>
inline T& write_poly(T& in)
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (direct_updating())
{
#if PERFORMING_VALIDATION
@@ -624,6 +692,7 @@
template <typename T>
inline void delete_memory(T const&in)
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (direct_updating())
{
#if PERFORMING_VALIDATION
@@ -641,12 +710,14 @@
//--------------------------------------------------------------------------
template <typename T>
inline void delete_tx_ptr(T *in) {
+BOOST_STM_TRANSACTION_INVARIANT;
delete_memory(*in);
}
//--------------------------------------------------------------------------
template <typename T>
inline void delete_non_tx_ptr(T *in) {
+BOOST_STM_TRANSACTION_INVARIANT;
if (direct_updating())
{
#if PERFORMING_VALIDATION
@@ -666,12 +737,14 @@
inline
typename boost::enable_if<is_base_of<base_transaction_object, T>, void>::type
delete_ptr(T *in, detail::dummy<0> = 0) {
+BOOST_STM_TRANSACTION_INVARIANT;
delete_tx_ptr(in);
}
template <typename T>
inline
typename boost::disable_if<is_base_of<base_transaction_object, T>, void>::type
delete_ptr(T *in, detail::dummy<1> = 0) {
+BOOST_STM_TRANSACTION_INVARIANT;
delete_non_tx_ptr(in);
}
#endif
@@ -679,6 +752,7 @@
//--------------------------------------------------------------------------
template <typename T>
inline void delete_tx_array(T *in, std::size_t size) {
+BOOST_STM_TRANSACTION_INVARIANT;
if (direct_updating())
{
#if PERFORMING_VALIDATION
@@ -695,6 +769,7 @@
//--------------------------------------------------------------------------
template <typename T>
inline void delete_non_tx_array(T *in, std::size_t size) {
+BOOST_STM_TRANSACTION_INVARIANT;
if (direct_updating())
{
#if PERFORMING_VALIDATION
@@ -732,9 +807,10 @@
//--------------------------------------------------------------------------
void throw_if_forced_to_abort_on_new() {
+BOOST_STM_TRANSACTION_INVARIANT;
if (forced_to_abort()) {
if (!direct_updating()) {
- deferred_abort(true);
+ deferred_abort(false);
throw aborted_tx("");
}
#ifndef DELAY_INVALIDATION_DOOMED_TXS_UNTIL_COMMIT
@@ -747,6 +823,7 @@
template <typename T>
T* as_new_tx(T *newNode)
{
+BOOST_STM_TRANSACTION_INVARIANT;
newNode->transaction_thread(threadId_);
newNode->new_memory(1);
newMemoryList().push_back(detail::make(newNode));
@@ -758,6 +835,7 @@
template <typename T>
T* as_new_non_tx(T *newNode)
{
+BOOST_STM_TRANSACTION_INVARIANT;
newMemoryList().push_back(detail::make_non_tx(newNode));
return newNode;
@@ -782,6 +860,7 @@
template <typename T>
T* as_new_tx_array(T *newNode, std::size_t size)
{
+BOOST_STM_TRANSACTION_INVARIANT;
newMemoryList().push_back(detail::make_array(newNode, size));
return newNode;
@@ -791,6 +870,7 @@
template <typename T>
T* as_new_non_tx_array(T *newNode, std::size_t size)
{
+BOOST_STM_TRANSACTION_INVARIANT;
newMemoryList().push_back(detail::make_array(newNode, size));
return newNode;
@@ -815,6 +895,7 @@
template <typename T>
T* new_shared_memory(T*/*ptr*/)
{
+BOOST_STM_TRANSACTION_INVARIANT;
throw_if_forced_to_abort_on_new();
make_irrevocable();
return as_new(new T());
@@ -824,6 +905,7 @@
template <typename T>
T* new_memory(T*/*ptr*/)
{
+BOOST_STM_TRANSACTION_INVARIANT;
throw_if_forced_to_abort_on_new();
return as_new(new T());
}
@@ -832,6 +914,7 @@
template <typename T>
T* new_memory_copy(T const &rhs)
{
+BOOST_STM_TRANSACTION_INVARIANT;
throw_if_forced_to_abort_on_new();
return as_new(new T(rhs));
}
@@ -842,6 +925,7 @@
inline bool restart_if_not_inflight()
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (in_flight()) return true;
else return restart();
}
@@ -850,6 +934,7 @@
void commit() { end(); }
void commit(std::nothrow_t)
{
+BOOST_STM_TRANSACTION_INVARIANT;
try { end(); }
catch (...) {}
}
@@ -857,7 +942,8 @@
void force_to_abort()
{
- // can't abort irrevocable transactions
+ BOOST_STM_TRANSACTION_INVARIANT;
+ // can't abort irrevocable transactions
if (irrevocable()) return;
*forced_to_abort_ptr() = true;
@@ -869,8 +955,8 @@
j != in_flight_transactions().end(); ++j)
{
BOOST_ASSERT(*j!=0);
-
- //~ (*j)->assert_tx_type();
+
+ BOOST_ASSERT((*j)->invariant());
transaction *t = *j;
// if this is a parent or child tx, it must abort too
@@ -879,7 +965,10 @@
#endif
#endif
}
- inline void unforce_to_abort() { *forced_to_abort_ptr() = false; }
+ inline void unforce_to_abort() {
+BOOST_STM_TRANSACTION_INVARIANT;
+ *forced_to_abort_ptr() = false;
+ }
//--------------------------------------------------------------------------
void lock_and_abort();
@@ -887,9 +976,13 @@
inline std::size_t writeListSize() const { return write_list()->size(); }
inline priority_t const &priority() const { return priority_; }
- inline void set_priority(priority_t const &rhs) const { priority_ = rhs; }
+ inline void set_priority(priority_t const &rhs) const {
+BOOST_STM_TRANSACTION_INVARIANT;
+ priority_ = rhs;
+ }
inline void raise_priority()
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (priority_ < priority_t(-1))
{
++priority_;
@@ -903,7 +996,6 @@
inline void make_isolated();
inline bool irrevocable() const;
inline bool isolated() const;
- inline void assert_tx_type() const;
inline thread_id_t const & thread_id() const { return threadId_; }
@@ -940,6 +1032,7 @@
template <typename T>
T const & direct_read(T const & in)
{
+ BOOST_STM_TRANSACTION_INVARIANT;
if (in.transaction_thread() == threadId_) return in;
if (forced_to_abort())
@@ -972,14 +1065,14 @@
// object from the thread that is changing it
//--------------------------------------------------------------------
//lock(&transactionMutex_);
- synchro::lock_guard<Mutex> guard_transactionMutex(transactionMutex_);
+ synchro::lock_guard<Mutex> guard_transactionMutex(transactionMutex_ BOOST_STM_CALL_CONTEXT("transactionMutex_"));
//lock_tx();
- synchro::lock_guard<Mutex> lock(*mutex());
+ synchro::lock_guard<Mutex> lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
if (in.transaction_thread() != invalid_thread_id())
{
- synchro::lock_guard<Mutex> guard(mutex(in.transaction_thread()));
+ synchro::lock_guard<Mutex> guard(mutex(in.transaction_thread()) BOOST_STM_CALL_CONTEXT("mutex")); // THREAD_INSTANCE
//Mutex& m=mutex(in.transaction_thread());
//stm::lock(m);
@@ -1025,7 +1118,7 @@
cm_abort_on_write(*this, (base_transaction_object&)(in));
}
- synchro::lock_guard<Mutex> lock(*mutex());
+ synchro::lock_guard<Mutex> lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
//lock_tx();
// already have locked us above - in both if / else
#ifndef DISABLE_READ_SETS
@@ -1044,6 +1137,7 @@
template <typename T, typename Poly>
T& direct_write(T& in)
{
+ BOOST_STM_TRANSACTION_INVARIANT;
// if this is our memory (new or mod global) just return
if (in.transaction_thread() == threadId_) return in;
@@ -1058,7 +1152,7 @@
// memory - since we need to ensure other threads don't try to
// manipulate this at the same time we are going to
//-----------------------------------------------------------------------
- synchro::lock_guard<Mutex> lock_m(transactionMutex_);
+ synchro::lock_guard<Mutex> lock_m(transactionMutex_ BOOST_STM_CALL_CONTEXT("transactionMutex_"));
// we currently don't allow write stealing in direct update. if another
// tx beat us to the memory, we abort
@@ -1079,6 +1173,7 @@
template <typename T>
void direct_delete_memory(T const&in)
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (in.transaction_thread() == threadId_)
{
deletedMemoryList().push_back(detail::make(in));
@@ -1090,7 +1185,7 @@
// and see if anyone else is writing to it. if not, we add the item to
// our write list and our deletedList
//-----------------------------------------------------------------------
- synchro::unique_lock<Mutex> lock_m(transactionMutex_);
+ synchro::unique_lock<Mutex> lock_m(transactionMutex_ BOOST_STM_CALL_CONTEXT("transactionMutex_"));
if (in.transaction_thread() != invalid_thread_id())
{
@@ -1112,6 +1207,7 @@
template <typename T>
void direct_delete_non_tx_ptr(T *in)
{
+BOOST_STM_TRANSACTION_INVARIANT;
//if (in.transaction_thread() == threadId_)
//{
// deletedMemoryList().push_back(detail::make(in));
@@ -1123,7 +1219,7 @@
// and see if anyone else is writing to it. if not, we add the item to
// our write list and our deletedList
//-----------------------------------------------------------------------
- synchro::unique_lock<Mutex> lock_m(transactionMutex_);
+ synchro::unique_lock<Mutex> lock_m(transactionMutex_ BOOST_STM_CALL_CONTEXT("transactionMutex_"));
//if (in.transaction_thread() != invalid_thread_id())
//{
@@ -1211,6 +1307,7 @@
template <typename T>
void direct_delete_tx_array(T *in, std::size_t size)
{
+BOOST_STM_TRANSACTION_INVARIANT;
bool all_in_this_thread = true;
for (int i=size-1; i>=0; --i) {
if (in[i].transaction_thread() != threadId_) {
@@ -1228,7 +1325,7 @@
// and see if anyone else is writing to it. if not, we add the item to
// our write list and our deletedList
//-----------------------------------------------------------------------
- synchro::unique_lock<Mutex> lock_m(transactionMutex_);
+ synchro::unique_lock<Mutex> lock_m(transactionMutex_ BOOST_STM_CALL_CONTEXT("transactionMutex_"));
bool all_invalid = true;
for (int i=size-1; i>=0; --i) {
@@ -1264,7 +1361,7 @@
{
if (forced_to_abort())
{
- deferred_abort(true);
+ deferred_abort(false);
throw aborted_tx("");
}
@@ -1294,6 +1391,7 @@
template <typename T>
T& insert_and_return_read_memory(T& in)
{
+BOOST_STM_TRANSACTION_INVARIANT;
#ifndef DISABLE_READ_SETS
//~ ReadContainer::iterator i = readList().find
//~ (static_cast<base_transaction_object*>(&in));
@@ -1305,7 +1403,7 @@
#else
if (bloom().exists((std::size_t)&in)) return in;
#endif
- synchro::lock_guard<Mutex> lock(*mutex());
+ synchro::lock_guard<Mutex> lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
//lock_tx();
#ifndef DISABLE_READ_SETS
#if PERFORMING_VALIDATION
@@ -1326,9 +1424,10 @@
template <typename T, typename Poly>
T& deferred_write(T& in)
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (forced_to_abort())
{
- deferred_abort(true);
+ deferred_abort(false);
throw aborted_tx("");
}
//----------------------------------------------------------------
@@ -1346,7 +1445,7 @@
if (i == writeList().end())
{
// get the lock before we make a copy of this object
- synchro::unique_lock<Mutex> lock(*mutex());
+ synchro::unique_lock<Mutex> lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
#if USE_BLOOM_FILTER
bloom().insert((std::size_t)&in);
lock.unlock();
@@ -1370,9 +1469,10 @@
template <typename T>
void deferred_delete_memory(T const&in)
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (forced_to_abort())
{
- deferred_abort(true);
+ deferred_abort(false);
throw aborted_tx("");
}
//-----------------------------------------------------------------------
@@ -1382,7 +1482,7 @@
if (in.transaction_thread() != invalid_thread_id())
{
{
- synchro::lock_guard<Mutex> lock(*mutex());
+ synchro::lock_guard<Mutex> lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
bloom().insert((std::size_t)&in);
}
writeList().insert(tx_pair(const_cast<T*>(&in), 0));
@@ -1395,7 +1495,7 @@
else
{
{
- synchro::lock_guard<Mutex> lock(*mutex());
+ synchro::lock_guard<Mutex> lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
bloom().insert((std::size_t)&in);
}
// check the ENTIRE write container for this piece of memory in the
@@ -1419,7 +1519,7 @@
{
if (forced_to_abort())
{
- deferred_abort(true);
+ deferred_abort(false);
throw aborted_tx("");
}
//-----------------------------------------------------------------------
@@ -1491,9 +1591,10 @@
template <typename T>
void deferred_delete_tx_array(T *in, std::size_t size)
{
+BOOST_STM_TRANSACTION_INVARIANT;
if (forced_to_abort())
{
- deferred_abort(true);
+ deferred_abort(false);
throw aborted_tx("");
}
//-----------------------------------------------------------------------
@@ -1509,7 +1610,7 @@
}
if (all_valid) {
{
- synchro::lock_guard<Mutex> lock(*mutex());
+ synchro::lock_guard<Mutex> lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
for (int i=size-1; i>=0; --i) {
bloom().insert((std::size_t)(&in[i]));
}
@@ -1526,7 +1627,7 @@
else
{
{
- synchro::lock_guard<Mutex> lock(*mutex());
+ synchro::lock_guard<Mutex> lock(*mutex() BOOST_STM_CALL_CONTEXT("mutex"));
for (int i=size-1; i>=0; --i) {
bloom().insert((std::size_t)(&in[i]));
}
@@ -1618,10 +1719,13 @@
void directAbortTransactionDeletedMemory() throw();
void deferredAbortTransactionDeletedMemory() throw() {
+BOOST_STM_TRANSACTION_INVARIANT;
#ifdef BOOST_STM_ALLOWS_DELETERS
for (MemoryContainerList::iterator i = deletedMemoryList().begin();
i != deletedMemoryList().end(); ++i)
{
+ BOOST_STM_TRANSACTION_INVARIANT;
+ BOOST_ASSERT(*i);
delete *i;
}
#endif
@@ -1643,7 +1747,7 @@
#ifndef DISABLE_READ_SETS
void directAbortReadList() { readList().clear(); }
- void deferredAbortReadList() throw() { readList().clear(); }
+ void deferredAbortReadList() throw() { BOOST_STM_TRANSACTION_INVARIANT; readList().clear(); }
#endif
void validating_direct_end_transaction();
@@ -1819,15 +1923,7 @@
// ******** WARNING ******** MOVING threadId_ WILL BREAK TRANSACTION
//--------------------------------------------------------------------------
-#ifndef BOOST_STM_USE_STACK
- transaction* parent_;
- public:
- void set_parent(transaction* tx) {parent_=tx;};
- transaction* parent() {return parent_;};
- private:
-#else
- bool nested_;
-#endif
+ //~ transaction_tss_storage & transaction_tss_storage_ref_;
synchro::unique_lock<Mutex> auto_general_lock_;
@@ -1837,10 +1933,11 @@
#ifndef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
////////////////////////////////////////
//public:
- tx_context &context_;
+ BOOST_STM_ASSERT_VAR_DCL(tx_context &, context_);
//private:
#ifdef BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
- mutable WriteContainer *write_list_ref_;
+ //~ mutable WriteContainer * const write_list_ref_;
+ BOOST_STM_ASSERT_VAR_DCL(WriteContainer * const, write_list_ref_);
inline WriteContainer *write_list() {
return write_list_ref_;
}
@@ -1848,9 +1945,11 @@
return write_list_ref_;
}
- mutable bloom_filter *bloomRef_;
+ //~ mutable bloom_filter * const bloomRef_;
+ bloom_filter * const bloomRef_;
#if PERFORMING_WRITE_BLOOM
- mutable bloom_filter *wbloomRef_;
+ //~ mutable bloom_filter * const wbloomRef_;
+ bloom_filter * const wbloomRef_;
//mutable bit_vector &sm_wbv_;
#endif
@@ -1859,13 +1958,13 @@
inline bloom_filter& wbloom() { return *wbloomRef_; }
//bit_vector& sm_wbv() { return sm_wbv_; }
#endif
- MemoryContainerList *newMemoryListRef_;
+ MemoryContainerList * const newMemoryListRef_;
inline MemoryContainerList& newMemoryList() { return *newMemoryListRef_; }
- MemoryContainerList *deletedMemoryListRef_;
+ MemoryContainerList * const deletedMemoryListRef_;
inline MemoryContainerList& deletedMemoryList() { return *deletedMemoryListRef_; }
- TxType *txTypeRef_;
+ BOOST_STM_ASSERT_VAR_DCL(TxType * const, txTypeRef_);
inline TxType const tx_type() const { return *txTypeRef_; }
inline void tx_type(TxType const &rhs) { *txTypeRef_ = rhs; }
inline TxType* tx_type_ptr() { return txTypeRef_; }
@@ -1891,7 +1990,7 @@
#ifdef USING_SHARED_FORCED_TO_ABORT
#ifdef BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
- int *forcedToAbortRef_;
+ int * const forcedToAbortRef_;
public:
inline int const forced_to_abort() const { return *forcedToAbortRef_; }
private:
@@ -1903,7 +2002,7 @@
inline int* forced_to_abort_ptr() { return &context_.abort; }
#endif
#else
- int forcedToAbortRef_;
+ int const forcedToAbortRef_;
public:
inline int const forced_to_abort() const { return forcedToAbortRef_; }
private:
@@ -1911,7 +2010,7 @@
#endif
static ThreadMutexContainer threadMutexes_;
- Mutex *mutexRef_;
+ Mutex * const mutexRef_;
inline Mutex * mutex() { return mutexRef_; }
inline static Mutex& mutex(thread_id_t id) {
ThreadMutexContainer::iterator i = threadMutexes_.find(id);
@@ -1920,7 +2019,7 @@
static ThreadBoolContainer threadBlockedLists_;
#if PERFORMING_LATM
- int &blockedRef_;
+ int & blockedRef_;
inline void block() { blockedRef_ = true; }
inline void unblock() { blockedRef_ = false; }
inline int const blocked() const { return blockedRef_; }
@@ -1934,7 +2033,7 @@
static latm::thread_id_mutex_set_map threadCurrentlyLockedLocks_;
#if USING_TRANSACTION_SPECIFIC_LATM
- latm::mutex_set &conflictingMutexRef_;
+ latm::mutex_set & conflictingMutexRef_;
inline latm::mutex_set& get_tx_conflicting_locks() { return conflictingMutexRef_; }
inline latm::mutex_set& get_tx_conflicting_locks(thread_id_t id) {
return *threadConflictingMutexes_.find(threadId_)->second;
@@ -1964,7 +2063,7 @@
}
#endif
- latm::mutex_set &obtainedLocksRef_;
+ latm::mutex_set & obtainedLocksRef_;
inline latm::mutex_set &obtainedLocksRef() {return obtainedLocksRef_;}
inline static latm::mutex_set &obtainedLocksRef(thread_id_t id) {return *threadObtainedLocks_.find(id)->second;}
@@ -1993,7 +2092,7 @@
}
}
- latm::mutex_set ¤tlyLockedLocksRef_;
+ BOOST_STM_ASSERT_VAR_DCL(latm::mutex_set &, currentlyLockedLocksRef_);
inline latm::mutex_set ¤tlyLockedLocksRef() {return currentlyLockedLocksRef_;}
inline static latm::mutex_set ¤tlyLockedLocksRef(thread_id_t id) {return *threadCurrentlyLockedLocks_.find(id)->second;}
#endif
@@ -2002,10 +2101,11 @@
////////////////////////////////////////
#else //BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
////////////////////////////////////////
- tss_context &context_;
+ tss_context & context_;
#ifdef BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
- mutable WriteContainer *write_list_ref_;
+ //~ mutable WriteContainer * const write_list_ref_;
+ BOOST_STM_ASSERT_VAR_DCL(WriteContainer * const, write_list_ref_);
inline WriteContainer *write_list() {
return write_list_ref_;
}
@@ -2013,9 +2113,11 @@
return write_list_ref_;
}
- mutable bloom_filter *bloomRef_;
+ //~ mutable bloom_filter * const bloomRef_;
+ bloom_filter * const bloomRef_;
#if PERFORMING_WRITE_BLOOM
- mutable bloom_filter *wbloomRef_;
+ //~ mutable bloom_filter * const wbloomRef_;
+ bloom_filter * const wbloomRef_;
//mutable bit_vector &sm_wbv_;
#endif
@@ -2024,13 +2126,13 @@
inline bloom_filter& wbloom() { return *wbloomRef_; }
//bit_vector& sm_wbv() { return sm_wbv_; }
#endif
- MemoryContainerList *newMemoryListRef_;
+ MemoryContainerList * const newMemoryListRef_;
inline MemoryContainerList& newMemoryList() { return *newMemoryListRef_; }
- MemoryContainerList *deletedMemoryListRef_;
+ MemoryContainerList * const deletedMemoryListRef_;
inline MemoryContainerList& deletedMemoryList() { return *deletedMemoryListRef_; }
- TxType *txTypeRef_;
+ BOOST_STM_ASSERT_VAR_DCL(TxType * const, txTypeRef_);
inline TxType const tx_type() const { return *txTypeRef_; }
inline void tx_type(TxType const &rhs) { *txTypeRef_ = rhs; }
inline TxType* tx_type_ptr() { return txTypeRef_; }
@@ -2056,7 +2158,7 @@
#ifdef USING_SHARED_FORCED_TO_ABORT
#ifdef BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
- int *forcedToAbortRef_;
+ int * const forcedToAbortRef_;
public:
inline int const forced_to_abort() const { return *forcedToAbortRef_; }
private:
@@ -2170,7 +2272,8 @@
#else // USE_SINGLE_THREAD_CONTEXT_MAP
////////////////////////////////////////
- mutable WriteContainer *write_list_ref_;
+ //~ mutable WriteContainer * const write_list_ref_;
+ BOOST_STM_ASSERT_VAR_DCL(WriteContainer * const, write_list_ref_);
inline WriteContainer *write_list() {
return write_list_ref_;
}
@@ -2178,11 +2281,14 @@
return write_list_ref_;
}
#ifndef DISABLE_READ_SETS
- mutable ReadContainer &readListRef_;
+ //~ mutable ReadContainer & readListRef_;
+ ReadContainer & readListRef_;
#endif
- mutable bloom_filter *bloomRef_;
+ //~ mutable bloom_filter * const bloomRef_;
+ bloom_filter * const bloomRef_;
#if PERFORMING_WRITE_BLOOM
- mutable bloom_filter *wbloomRef_;
+ //~ mutable bloom_filter * const wbloomRef_;
+ bloom_filter * const wbloomRef_;
//mutable bit_vector &sm_wbv_;
#endif
@@ -2191,19 +2297,19 @@
inline bloom_filter& wbloom() { return *wbloomRef_; }
//bit_vector& sm_wbv() { return sm_wbv_; }
#endif
- MemoryContainerList *newMemoryListRef_;
+ MemoryContainerList * const newMemoryListRef_;
inline MemoryContainerList& newMemoryList() { return *newMemoryListRef_; }
- MemoryContainerList *deletedMemoryListRef_;
+ MemoryContainerList * const deletedMemoryListRef_;
inline MemoryContainerList& deletedMemoryList() { return *deletedMemoryListRef_; }
- TxType *txTypeRef_;
+ BOOST_STM_ASSERT_VAR_DCL(TxType * const, txTypeRef_);
inline TxType const tx_type() const { return *txTypeRef_; }
inline void tx_type(TxType const &rhs) { *txTypeRef_ = rhs; }
inline TxType* tx_type_ptr() { return txTypeRef_; }
#ifdef USING_SHARED_FORCED_TO_ABORT
- int *forcedToAbortRef_;
+ int * const forcedToAbortRef_;
public:
inline int const forced_to_abort() const { return *forcedToAbortRef_; }
private:
@@ -2217,7 +2323,7 @@
#endif
static ThreadMutexContainer threadMutexes_;
- Mutex *mutexRef_;
+ Mutex * const mutexRef_;
inline Mutex * mutex() { return mutexRef_; }
inline static Mutex& mutex(thread_id_t id) {
ThreadMutexContainer::iterator i = threadMutexes_.find(id);
@@ -2226,7 +2332,7 @@
static ThreadBoolContainer threadBlockedLists_;
#if PERFORMING_LATM
- int &blockedRef_;
+ int & blockedRef_;
inline void block() { blockedRef_ = true; }
inline void unblock() { blockedRef_ = false; }
inline int const blocked() const { return blockedRef_; }
@@ -2240,7 +2346,7 @@
static latm::thread_id_mutex_set_map threadCurrentlyLockedLocks_;
#if USING_TRANSACTION_SPECIFIC_LATM
- latm::mutex_set &conflictingMutexRef_;
+ latm::mutex_set & conflictingMutexRef_;
inline latm::mutex_set& get_tx_conflicting_locks() { return conflictingMutexRef_; }
inline latm::mutex_set& get_tx_conflicting_locks(thread_id_t id) {
return *threadConflictingMutexes_.find(threadId_)->second;
@@ -2270,7 +2376,7 @@
}
#endif
- latm::mutex_set &obtainedLocksRef_;
+ latm::mutex_set & obtainedLocksRef_;
inline latm::mutex_set &obtainedLocksRef() {return obtainedLocksRef_;}
inline static latm::mutex_set &obtainedLocksRef(thread_id_t id) {return *threadObtainedLocks_.find(id)->second;}
@@ -2301,7 +2407,7 @@
- latm::mutex_set ¤tlyLockedLocksRef_;
+ BOOST_STM_ASSERT_VAR_DCL(latm::mutex_set &, currentlyLockedLocksRef_);
inline latm::mutex_set ¤tlyLockedLocksRef() {return currentlyLockedLocksRef_;}
inline static latm::mutex_set ¤tlyLockedLocksRef(thread_id_t id) {return *threadCurrentlyLockedLocks_.find(id)->second;}
#endif
@@ -2312,9 +2418,9 @@
static synchro::implicit_thread_specific_ptr<transaction_tss_storage> transaction_tss_storage_;
- transaction_tss_storage & transaction_tss_storage_ref_;
public:
- inline TransactionsStack& transactions() {return transaction_tss_storage_ref_.transactions_;}
+ //~ inline TransactionsStack& transactions() {return transaction_tss_storage_ref_.transactions_;}
+ inline static TransactionsStack& transactions() {return transaction_tss_storage_->transactions_;}
// transaction specific data
//int hasMutex_; // bool - 1 bit
@@ -2323,6 +2429,51 @@
std::size_t reads_;
mutable clock_t startTime_;
+#ifndef BOOST_STM_USE_STACK
+ BOOST_STM_ASSERT_VAR_DCL(transaction* const, parent_);
+ public:
+ transaction* parent() const {return parent_;};
+ private:
+#else
+ BOOST_STM_ASSERT_VAR_DCL(bool const, nested_);
+#endif
+ unsigned int assert_end_flag_;
+ public:
+#ifdef BOOST_STM_USE_INVARIANT
+ bool invariant() const {
+#ifdef USE_SINGLE_THREAD_CONTEXT_MAP
+////////////////////////////////////////
+#ifndef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
+ BOOST_STM_RET_IF_FALSE(&context_==&assert_context_);
+
+#ifdef BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
+ BOOST_STM_RET_IF_FALSE(write_list_ref_==assert_write_list_ref_);
+#else // BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
+#endif
+
+#else // BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
+#endif
+#else // USE_SINGLE_THREAD_CONTEXT_MAP
+#endif
+
+#if PERFORMING_LATM
+ BOOST_STM_RET_IF_FALSE(¤tlyLockedLocksRef_==&assert_currentlyLockedLocksRef_);
+#endif
+
+ BOOST_STM_RET_IF_FALSE(txTypeRef_==assert_txTypeRef_);
+
+#ifndef BOOST_STM_USE_STACK
+ BOOST_STM_RET_IF_FALSE(parent_==assert_parent_);
+ BOOST_STM_RET_IF_FALSE(parent_!=this);
+#else
+ BOOST_STM_RET_IF_FALSE(nested_==assert_nested_);
+#endif
+ BOOST_STM_RET_IF_FALSE(assert_end_flag_==0xffffffff);
+
+ return true;
+ }
+#endif
+ private:
inline transaction_state const & state() const { return state_; }
inline WriteContainer& writeList() {
@@ -2333,11 +2484,11 @@
#endif
public:
- inline static transaction* current_transaction() {return transaction_tss_storage_->transactions_.top();}
+ inline static transaction* current() {return transaction_tss_storage_->transactions_.top();}
};
-inline transaction* current_transaction() {return transaction::current_transaction();}
+inline transaction* current_transaction() {return transaction::current();}
template <typename M>
inline void lock(M& m, latm::mutex_type& lock) {transaction::lock(m, lock);}
@@ -2393,7 +2544,7 @@
#ifndef BOOST_STM_USE_STACK
void transactions_stack::push(transaction* ptr) {
- ptr->set_parent(inner_);
+ //ptr->set_parent(inner_);
inner_ = ptr;
++count_;
}
@@ -2401,7 +2552,7 @@
inner_ = inner_->parent();
--count_;
}
-#endif
+#endif
}
} // stm namespace
} // boost namespace
Modified: sandbox/stm/branches/vbe/boost/stm/tx/proxy_cache.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/proxy_cache.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/proxy_cache.hpp 2010-03-14 17:33:15 EDT (Sun, 14 Mar 2010)
@@ -65,7 +65,7 @@
ref()+=rhs;
return *this;
}
-
+
template<typename F, typename U>
proxy_cache& operator-=(proxy_cache<F,U> const& rhs) {
ref()-=rhs.value();
@@ -171,18 +171,20 @@
return *this;
}
- T operator++(int) {
- return ref()++;
+ proxy_cache operator++(int) {
+ ref()++;
+ return *this;
}
proxy_cache& operator--() {
--ref();
return *this;
}
- T operator--(int) {
- return ref()--;
+ proxy_cache operator--(int) {
+ ref()--;
+ return *this;
}
-
+
operator T() const { return value(); }
//operator T&() { return ref(); }
@@ -230,11 +232,29 @@
};
template <typename Final, typename T, typename Base>
-typename proxy_cache<Final,Base>::value_type&
-ref(proxy_cache<Final,Base>& r) {
+typename proxy_cache<Final,T,Base>::value_type&
+write(proxy_cache<Final,T,Base>& r) {
return r.ref();
}
+template <typename Final, typename T, typename Base>
+typename proxy_cache<Final,T,Base>::value_type*
+write(proxy_cache<Final,T,Base>* r) {
+ return &r->ref();
+}
+
+template <typename Final, typename T, typename Base>
+typename proxy_cache<Final,T,Base>::value_type
+read(proxy_cache<Final,T,Base> const& r) {
+ return r.value();
+}
+
+template <typename Final, typename T, typename Base>
+typename proxy_cache<Final,T,Base>::value_type*
+read(proxy_cache<Final,T,Base> const* r) {
+ return r->value();
+}
+
template <typename OSTREAM, typename F, typename T, typename B>
OSTREAM& operator<<(OSTREAM& os, proxy_cache<F, T, B> const& r) {
os << r.value();
@@ -255,7 +275,7 @@
struct has_shallow_copy_semantics<tx::proxy_cache<F,T,B> > : boost::mpl::true_
{};
-
+
}}
#endif //BOOST_STM_TX_PROXY_CACHE__HPP
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