Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59907 - in sandbox/stm/branches/vbe/boost/stm: . detail non_tx/detail synch
From: vicente.botet_at_[hidden]
Date: 2010-02-25 12:14:48


Author: viboes
Date: 2010-02-25 12:14:46 EST (Thu, 25 Feb 2010)
New Revision: 59907
URL: http://svn.boost.org/trac/boost/changeset/59907

Log:
Boost.STM/vbe:
* Simplify commit_on_destruction, as there is no need to avoid throwing following the advice of Stefan.
* Add some assertion helping debugging.
* improve is_nested function
Text files modified:
   sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 5 +
   sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp | 7 +
   sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp | 7 +
   sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp | 10 +
   sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp | 7 +
   sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp | 7 +
   sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp | 12 +-
   sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp | 20 ++-
   sandbox/stm/branches/vbe/boost/stm/detail/memory_pool.hpp | 28 ++++-
   sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp | 182 ++++++++++++++++++++++++++++++++++-----
   sandbox/stm/branches/vbe/boost/stm/exceptions.hpp | 32 +++++-
   sandbox/stm/branches/vbe/boost/stm/language_like.hpp | 171 ++++++++++++++++++++++--------------
   sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp | 8 +
   sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp | 16 +-
   sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp | 24 ++++
   sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp | 13 +
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 61 +++++-------
   17 files changed, 427 insertions(+), 183 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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -195,6 +195,11 @@
 #define BOOST_STM_LATM_GENERIC 1
 
 ///////////////////////////////////////////////////////////////////////////////
+// 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
 
 

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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -65,7 +65,8 @@
         for (InflightTxes::iterator i = transactionsInFlight_.begin();
                 i != transactionsInFlight_.end(); ++i)
         {
- //transaction *t = (transaction*)*i;
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
             transaction *t = *i;
 
             if (!t->irrevocable() &&
@@ -81,6 +82,8 @@
 
         for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
         {
+ BOOST_ASSERT(*it!=0);
+
             (*it)->force_to_abort();
         }
     }
@@ -204,7 +207,7 @@
             // this is illegal, it means the transaction is unlocking a lock
             // it did not obtain (e.g., early release) while the transaction
             // is still in-flight. Throw exception
- throw "lock released for transaction that did not obtain it";
+ BOOST_ASSERT(false&& "lock released for transaction that did not obtain it");
         }
 
         if (!t->is_currently_locked_lock(&mutex)) hasLock = false;

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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -72,7 +72,8 @@
             for (InflightTxes::iterator i = transactionsInFlight_.begin();
                 i != transactionsInFlight_.end(); ++i)
             {
- //transaction *t = (transaction*)*i;
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
                 transaction *t = *i;
 
                 if (!t->irrevocable() &&
@@ -85,6 +86,8 @@
 
             for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
             {
+ BOOST_ASSERT(*it!=0);
+
                 (*it)->force_to_abort();
             }
         }
@@ -211,7 +214,7 @@
             // this is illegal, it means the transaction is unlocking a lock
             // it did not obtain (e.g., early release) while the transaction
             // is still in-flight. Throw exception
- throw "lock released for transaction that did not obtain it";
+ BOOST_ASSERT(false&& "lock released for transaction that did not obtain it");
         }
 
         if (!t->is_currently_locked_lock(&mutex)) hasLock = false;

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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -59,7 +59,8 @@
     for (InflightTxes::iterator i = transactionsInFlight_.begin();
       i != transactionsInFlight_.end(); ++i)
     {
- //transaction *t = (transaction*)*i;
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
         transaction *t = *i;
 
         // if this tx is part of this thread, skip it (it's an LiT)
@@ -86,7 +87,8 @@
 
         for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
         {
- //transaction *t = (transaction*)*it;
+ BOOST_ASSERT(*it!=0);
+
             transaction *t = *it;
 
             t->force_to_abort();
@@ -205,7 +207,7 @@
 {
     //--------------------------------------------------------------------------
 
- throw "might not be possible to implement trylock for this";
+ BOOST_ASSERT(false&& "might not be possible to implement trylock for this");
 
     bool txIsIrrevocable = false;
 
@@ -257,7 +259,7 @@
             // this is illegal, it means the transaction is unlocking a lock
             // it did not obtain (e.g., early release) while the transaction
             // is still in-flight. Throw exception
- throw "lock released for transaction that did not obtain it";
+ BOOST_ASSERT(false&& "lock released for transaction that did not obtain it");
         }
 
         if (!t->is_currently_locked_lock(&mutex)) hasLock = false;

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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -67,7 +67,8 @@
         for (InflightTxes::iterator i = transactionsInFlight_.begin();
             i != transactionsInFlight_.end(); ++i)
         {
- //transaction *t = (transaction*)*i;
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
             transaction *t = *i;
 
             if (!t->irrevocable() &&
@@ -83,6 +84,8 @@
 
         for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
         {
+ BOOST_ASSERT(*it!=0);
+
             (*it)->force_to_abort();
         }
 
@@ -219,7 +222,7 @@
         // this is illegal, it means the transaction is unlocking a lock
         // it did not obtain (e.g., early release) while the transaction
         // is still in-flight. Throw exception
- throw "lock released for transaction that did not obtain it";
+ BOOST_ASSERT(false&& "lock released for transaction that did not obtain it");
         }
 
         if (!t->is_currently_locked_lock(&mutex)) hasLock = false;

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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -74,7 +74,8 @@
             for (InflightTxes::iterator i = transactionsInFlight_.begin();
                 i != transactionsInFlight_.end(); ++i)
             {
- //~ transaction *t = (transaction*)*i;
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
                 transaction *t = *i;
 
                 if (!t->irrevocable() &&
@@ -90,6 +91,8 @@
 
             for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
             {
+ BOOST_ASSERT(*it!=0);
+
                 (*it)->force_to_abort();
             }
 
@@ -215,7 +218,7 @@
             // this is illegal, it means the transaction is unlocking a lock
             // it did not obtain (e.g., early release) while the transaction
             // is still in-flight. Throw exception
- throw "lock released for transaction that did not obtain it";
+ BOOST_ASSERT(false&& "lock released for transaction that did not obtain it");
         }
 
         if (!t->is_currently_locked_lock(&mutex)) hasLock = false;

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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -61,7 +61,8 @@
     for (InflightTxes::iterator i = transactionsInFlight_.begin();
             i != transactionsInFlight_.end(); ++i)
     {
- //~ transaction *t = (transaction*)*i;
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
         transaction *t = *i;
 
         // if this tx is part of this thread, skip it (it's an LiT)
@@ -85,7 +86,7 @@
     {
         for (std::list<transaction*>::iterator it = txList.begin(); txList.end() != it; ++it)
         {
- //~ transaction *t = (transaction*)*it;
+ BOOST_ASSERT(*it!=0);
             transaction *t = *it;
 
             t->force_to_abort();
@@ -130,7 +131,8 @@
             for (InflightTxes::iterator i = transactionsInFlight_.begin();
                 i != transactionsInFlight_.end(); ++i)
             {
- //~ transaction *t = (transaction*)*i;
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
                 transaction *t = *i;
 
                 if (t->get_tx_conflicting_locks().find(mutex) != t->get_tx_conflicting_locks().end())
@@ -235,7 +237,7 @@
 inline bool transaction::dir_tx_try_lock(M& m, latm::mutex_type& mutex)
 {
     //--------------------------------------------------------------------------
- throw "might not be possible to implement trylock for this";
+ throw invalid_operation("might not be possible to implement trylock for this");
 
     bool txIsIrrevocable = false;
 
@@ -282,7 +284,7 @@
             // this is illegal, it means the transaction is unlocking a lock
             // it did not obtain (e.g., early release) while the transaction
             // is still in-flight. Throw exception
- throw "lock released for transaction that did not obtain it";
+ throw aborted_transaction_exception_error("lock released for transaction that did not obtain it");
         }
 
         if (!t->is_currently_locked_lock(&mutex)) hasLock = false;

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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -162,6 +162,8 @@
    for (tss_context_map_type::iterator iter = tss_context_map_.begin();
    tss_context_map_.end() != iter; ++iter)
    {
+ BOOST_ASSERT(iter->second!=0);
+
       if (iter->second->obtainedLocks_.find(mutex) != iter->second->obtainedLocks_.end())
       {
          return true;
@@ -171,6 +173,7 @@
    for (latm::thread_id_mutex_set_map::iterator iter = threadObtainedLocks_.begin();
    threadObtainedLocks_.end() != iter; ++iter)
    {
+ BOOST_ASSERT(iter->second!=0);
       if (iter->second->find(mutex) != iter->second->end())
       {
          return true;
@@ -220,6 +223,7 @@
       for (latm::thread_id_mutex_set_map::iterator it = threadObtainedLocks_.begin();
       it != threadObtainedLocks_.end(); ++it)
       {
+ BOOST_ASSERT(it->second!=0);
          if (!it->second->empty()) return;
       }
       thread_conflicting_mutexes_set_all(false);
@@ -263,7 +267,8 @@
 {
    if (tmConflictingLocks_.find(inLock) == tmConflictingLocks_.end())
    {
- throw "lock not in tx conflict lock set, use add_tm_conflicting_lock";
+ BOOST_ASSERT(false&&"lock not in tx conflict lock set, use add_tm_conflicting_lock");
+ //~ throw "lock not in tx conflict lock set, use add_tm_conflicting_lock";
    }
 }
 #endif
@@ -274,7 +279,7 @@
 {
    if (get_tx_conflicting_locks().find(inLock) == get_tx_conflicting_locks().end())
    {
- throw "lock not in tx conflict lock set, use add_tx_conflicting_lock";
+ BOOST_ASSERT(false&&"lock not in tx conflict lock set, use add_tx_conflicting_lock");
    }
 }
 
@@ -337,7 +342,7 @@
       if (direct_updating()) {dir_tx_lock(m, mutex);return;}
       else {def_tx_lock(m, mutex);return;}
    default:
- throw "invalid LATM type";
+ BOOST_ASSERT(false&&"invalid LATM type");
    }
 }
 
@@ -361,7 +366,7 @@
       if (direct_updating()) return dir_tx_try_lock(m, mutex);
       else return def_tx_try_lock(m, mutex);
    default:
- throw "invalid LATM type";
+ BOOST_ASSERT(false&&"invalid LATM type");
    }
 }
 
@@ -384,7 +389,7 @@
       if (direct_updating()) {dir_tx_unlock(m, mutex);return;}
       else {def_tx_unlock(m, mutex);return;}
    default:
- throw "invalid LATM type";
+ BOOST_ASSERT(false&&"invalid LATM type");
    }
 }
 
@@ -434,7 +439,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,7 +489,8 @@
    for (InflightTxes::iterator i = transactionsInFlight_.begin();
       i != transactionsInFlight_.end(); ++i)
    {
- //~ transaction *t = (transaction*)*i;
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
       transaction *t = *i;
 
       //--------------------------------------------------------------------

Modified: sandbox/stm/branches/vbe/boost/stm/detail/memory_pool.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/memory_pool.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/memory_pool.hpp 2010-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -21,6 +21,7 @@
 #include <memory.h>
 #include <map>
 #include <vector>
+#include <boost/stm/trace.hpp>
 
 #include <boost/stm/detail/vector_map.hpp>
 
@@ -41,13 +42,20 @@
    explicit FixedReserve(size_t const &amount, size_t const &size) :
       allocSize_(amount), currentLoc_(0), currentSize_(0), chunk_(size), data_(0)
    {
- if (allocSize_ < 1) throw "invalid allocation size";
+ if (allocSize_ < 1) BOOST_ASSERT(false&& "invalid allocation size");
       data_.reserve(allocSize_ * 2);
       allocateBlock(allocSize_);
    }
 
    //////////////////////////////////////////////////////////////////////////
- ~FixedReserve() { freeAllocatedMem(); }
+ ~FixedReserve() {
+ try {
+ freeAllocatedMem();
+ } catch (...) {
+ BOOST_STM_ERROR;
+ }
+ }
+
 
    //////////////////////////////////////////////////////////////////////////
    void* retrieveFixedChunk()
@@ -122,12 +130,16 @@
    //////////////////////////////////////////////////////////////////////////
    ~MemoryPool()
    {
- typename MemoryMap::iterator iter;
- // wipe out all the FixedReserves we created
- for (iter = mem.begin(); mem.end() != iter; ++iter)
- {
- delete iter->second;
- }
+ try {
+ typename MemoryMap::iterator iter;
+ // wipe out all the FixedReserves we created
+ for (iter = mem.begin(); mem.end() != iter; ++iter)
+ {
+ delete iter->second;
+ }
+ } catch (...) {
+ BOOST_STM_ERROR;
+ }
    }
 
    //////////////////////////////////////////////////////////////////////////

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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -44,16 +44,24 @@
 //--------------------------------------------------------------------------
 inline bool transaction::isolatedTxInFlight()
 {
+ BOOST_STM_INFO;
+ assert_tx_type();
+ //~ BOOST_STM_INFO;
    for (InflightTxes::iterator i = transactionsInFlight_.begin();
       i != transactionsInFlight_.end(); ++i)
    {
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
+
+ //~ BOOST_STM_INFO;
       // if this is our threadId, skip it
- //if (((transaction*)*i)->threadId_ == this->threadId_) continue;
       if ((*i)->threadId_ == this->threadId_) continue;
+ //~ BOOST_STM_INFO;
 
- //if (((transaction*)*i)->isolated()) return true;
       if ((*i)->isolated()) return true;
+ //~ BOOST_STM_INFO;
    }
+ //~ BOOST_STM_INFO;
 
    return false;
 }
@@ -68,10 +76,12 @@
    for (InflightTxes::iterator i = transactionsInFlight_.begin();
       i != transactionsInFlight_.end(); ++i)
    {
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
       // if this is our threadId, skip it
- if (((transaction*)*i)->threadId_ == this->threadId_) continue;
+ if ((*i)->threadId_ == this->threadId_) continue;
 
- if (((transaction*)*i)->irrevocable()) return true;
+ if ((*i)->irrevocable()) return true;
    }
 
    return false;
@@ -88,10 +98,12 @@
    for (InflightTxes::iterator i = transactionsInFlight_.begin();
       i != transactionsInFlight_.end(); ++i)
    {
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
       // if this is our threadId, skip it
- if (((transaction*)*i)->threadId_ == this->threadId_) continue;
+ if ((*i)->threadId_ == this->threadId_) continue;
 
- ((transaction*)*i)->force_to_abort();
+ (*i)->force_to_abort();
    }
 
    return true;
@@ -107,10 +119,12 @@
    for (InflightTxes::iterator i = transactionsInFlight_.begin();
       i != transactionsInFlight_.end(); ++i)
    {
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
       // if this is our threadId, skip it
- if (((transaction*)*i)->threadId_ == this->threadId_) continue;
+ if ((*i)->threadId_ == this->threadId_) continue;
 
- if (cm_permission_to_abort(*((transaction*)*i), *this)) return false;
+ if (cm_permission_to_abort(*(*i), *this)) return false;
    }
 
    return true;
@@ -189,7 +203,8 @@
    case eIrrevocableTx: return true;
    case eIrrevocableAndIsolatedTx: return true;
    default:
- throw "tx type not found";
+ BOOST_ASSERT(false&&"tx type not found");
+ return false;
    }
 }
 
@@ -203,7 +218,20 @@
    case eIrrevocableTx: return false;
    case eIrrevocableAndIsolatedTx: return true;
    default:
- throw "tx type not found";
+ BOOST_ASSERT(false&&"tx type not found");
+ return false;
+ }
+}
+
+inline void transaction::assert_tx_type() const
+{
+ switch (tx_type())
+ {
+ case eNormalTx: return ;
+ case eIrrevocableTx: return ;
+ case eIrrevocableAndIsolatedTx: return ;
+ default:
+ BOOST_STM_ERROR;
    }
 }
 
@@ -217,7 +245,7 @@
 inline void transaction::commit_deferred_update_tx()
 {
    // ensure this method is isolated
- if (!this->irrevocable()) throw "cannot commit deferred tx: not isolated";
+ if (!this->irrevocable()) throw invalid_operation("cannot commit deferred tx: not isolated");
 
    //--------------------------------------------------------------------------
    // otherwise, force the tx to commit its writes/reads
@@ -291,6 +319,8 @@
     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_);
    }
@@ -299,6 +329,8 @@
       i != threadMutexes_.end(); ++i)
    {
       if (i->first == threadId) continue;
+ BOOST_ASSERT(i->second!=0);
+
       synchro::lock(*(i->second));
    }
 #endif
@@ -319,6 +351,9 @@
       i != threadMutexes_.end(); ++i)
    {
       if (i->first == threadId) continue;
+
+ BOOST_ASSERT(i->second!=0);
+
       synchro::unlock(*(i->second));
    }
 #endif
@@ -332,12 +367,16 @@
     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_);
    }
 #else
    for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
       i != threadMutexes_.end(); ++i)
    {
+ BOOST_ASSERT(i->second!=0);
+
       synchro::lock(*(i->second));
    }
 #endif
@@ -356,12 +395,14 @@
     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_);
    }
 #else
    for (ThreadMutexContainer::iterator i = threadMutexes_.begin();
       i != threadMutexes_.end(); ++i)
    {
+ BOOST_ASSERT(i->second!=0);
       synchro::unlock(*(i->second));
    }
 #endif
@@ -386,6 +427,7 @@
 
 #if USE_SINGLE_THREAD_CONTEXT_MAP
 ////////////////////////////////////////
+// BUG possible core dump if find doesn't suceed
    context_(*tss_context_map_.find(threadId_)->second),
 
 #ifdef BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
@@ -424,9 +466,12 @@
 
 #if PERFORMING_LATM
 #if USING_TRANSACTION_SPECIFIC_LATM
+// BUG possible core dump if find doesn't suceed
    conflictingMutexRef_(*threadConflictingMutexes_.find(threadId_)->second),
 #endif
+// 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),
 #endif
 #endif
@@ -434,6 +479,7 @@
 #else
 ////////////////////////////////////////
 #ifndef DISABLE_READ_SETS
+// BUG possible core dump if find doesn't suceed
    readListRef_(*threadReadLists_.find(threadId_)->second),
 #endif
    write_list_ref_(threadWriteLists_.find(threadId_)->second),
@@ -459,8 +505,10 @@
 
 #if PERFORMING_LATM
 #if USING_TRANSACTION_SPECIFIC_LATM
+// BUG possible core dump if find doesn't suceed
    conflictingMutexRef_(*threadConflictingMutexes_.find(threadId_)->second),
 #endif
+// BUG possible core dump if find doesn't suceed
    obtainedLocksRef_(*threadObtainedLocks_.find(threadId_)->second),
    currentlyLockedLocksRef_(*threadCurrentlyLockedLocks_.find(threadId_)->second),
 #endif
@@ -473,6 +521,7 @@
    reads_(0),
    startTime_(time(0))
 {
+ nested_=(current_transaction()!=0);
    auto_general_lock_.unlock();
    if (direct_updating()) doIntervalDeletions();
 #if PERFORMING_LATM
@@ -545,12 +594,19 @@
 //--------------------------------------------------------------------------
 inline bool transaction::restart()
 {
+ BOOST_STM_INFO;
+ assert_tx_type();
+ //~ BOOST_STM_INFO;
    if (e_in_flight == state_) lock_and_abort();
+ //~ BOOST_STM_INFO;
 
 #if PERFORMING_LATM
 #ifdef LOGGING_BLOCKS
+ //~ BOOST_STM_INFO;
    int iterations = 0;
+ //~ BOOST_STM_INFO;
 #endif
+ //~ BOOST_STM_INFO;
    while (blocked())
    {
 #ifdef LOGGING_BLOCKS
@@ -567,6 +623,7 @@
       SLEEP(10);
    }
 #endif
+ //~ BOOST_STM_INFO;
    //-----------------------------------------------------------------------
    // this is a vital check for composed transactions that abort, but the
    // outer instance tx is never destructed, but instead restarted via
@@ -576,17 +633,26 @@
 #ifdef USING_SHARED_FORCED_TO_ABORT
    {
    synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ //~ BOOST_STM_INFO;
    if (!otherInFlightTransactionsOfSameThreadNotIncludingThis(this))
    {
+ //~ BOOST_STM_INFO;
       unforce_to_abort();
+ //~ BOOST_STM_INFO;
    }
    }
 #else
+ //~ BOOST_STM_INFO;
    unforce_to_abort();
+ //~ BOOST_STM_INFO;
 #endif
 #endif
 
+ BOOST_STM_INFO;
+ assert_tx_type();
+ //~ BOOST_STM_INFO;
    put_tx_inflight();
+ //~ BOOST_STM_INFO;
 
 #if 0
    if (doing_dynamic_priority_assignment())
@@ -597,6 +663,7 @@
    reads_ = 0;
 #endif
 
+ //~ BOOST_STM_INFO;
    return true;
 }
 
@@ -648,46 +715,71 @@
 //--------------------------------------------------------------------------
 inline void transaction::put_tx_inflight()
 {
+ BOOST_STM_INFO;
+ assert_tx_type();
+ //~ BOOST_STM_INFO;
 #if PERFORMING_LATM
    while (true)
    {
+ //~ BOOST_STM_INFO;
       {
       synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ //~ BOOST_STM_INFO;
 
- if (latm::instance().can_go_inflight() && !isolatedTxInFlight())
+ bool b1=latm::instance().can_go_inflight();
+ //~ BOOST_STM_INFO;
+ bool b2=!isolatedTxInFlight();
+ //~ BOOST_STM_INFO;
+ if (b1 && b2)
       {
+ //~ BOOST_STM_INFO;
          transactionsInFlight_.insert(this);
          state_ = e_in_flight;
          break;
       }
+ //~ BOOST_STM_INFO;
 
       }
       SLEEP(10);
    }
 #else
    synchro::lock_guard<Mutex> lock_i(*inflight_lock());
+ //~ BOOST_STM_INFO;
    transactionsInFlight_.insert(this);
+ //~ BOOST_STM_INFO;
    state_ = e_in_flight;
 #endif
+ BOOST_STM_INFO;
+ assert_tx_type();
+ //~ BOOST_STM_INFO;
 }
 
 //--------------------------------------------------------------------------
 //--------------------------------------------------------------------------
 inline transaction::~transaction()
 {
+ BOOST_STM_INFO;
+ assert_tx_type();
+ BOOST_STM_INFO;
    // if we're not an inflight transaction - bail
    if (state_ != e_in_flight)
    {
+ BOOST_STM_INFO;
       //if (hasLock()) unlock_tx();
       return;
    }
 
+ BOOST_STM_INFO;
     //if (!hasLock())
     {
        synchro::lock_guard<Mutex> lock(*mutex());
+ BOOST_STM_INFO;
         abort();
+ BOOST_STM_INFO;
     }
+ BOOST_STM_INFO;
     transactions().pop();
+ BOOST_STM_INFO;
 
     // BUG not removed from the list because the test is inversed
     //~ if (alreadyRemovedFromInFlight)
@@ -834,6 +926,7 @@
          synchro::unlock(*general_lock());
          synchro::unlock(*inflight_lock());
       } else {
+ BOOST_STM_ERROR;
           std::cout << "invalidating_direct_end_transaction e_committed != state_" << std::endl;
       }
    }
@@ -934,6 +1027,7 @@
         //synchro::unique_lock<Mutex> lk_i(*inflight_lock());
 
 #if PERFORMING_COMPOSITION
+ // BUG
       if (other_in_flight_same_thread_transactions())
       {
          transactionsInFlight_.erase(this);
@@ -1171,7 +1265,9 @@
       for (InflightTxes::iterator j = transactionsInFlight_.begin();
       j != transactionsInFlight_.end();)
       {
- transaction *t = (transaction*)*j;
+ BOOST_ASSERT(*j!=0);
+ (*j)->assert_tx_type();
+ transaction *t = *j;
 
          // if we're already aborting for this transaction, skip it
          if (t->forced_to_abort()) {++j; continue;}
@@ -1227,6 +1323,7 @@
    // ok, forced to aborts are allowed, do them
    for (std::list<transaction*>::iterator k = aborted.begin(); k != aborted.end();)
    {
+ BOOST_ASSERT(k!=0);
       (*k)->force_to_abort();
       transactionsInFlight_.erase(*k);
    }
@@ -1287,6 +1384,7 @@
    }
    catch (...)
    {
+ BOOST_STM_ERROR;
       std::cout << "Exception caught in abort - bad" << std::endl;
    }
 }
@@ -1507,8 +1605,11 @@
 #endif
       }
 
- transactionsInFlight_.erase(this);
+ //BUG
+ //~ transactionsInFlight_.erase(this);
+ //~ synchro::unlock(*inflight_lock());
       synchro::unlock(*inflight_lock());
+ transactionsInFlight_.erase(this);
       synchro::unlock(*general_lock());
 
       deferredCommitWriteState();
@@ -1583,7 +1684,7 @@
 ////////////////////////////////////////////////////////////////////////////
 inline void transaction::validating_direct_commit()
 {
- throw "not implemented yet";
+ throw not_implemented("not implemented yet: validating_direct_commit";
 
 
 
@@ -1775,7 +1876,11 @@
 ////////////////////////////////////////////////////////////////////////////
 inline void transaction::unlockAllLockedThreads(LockedTransactionContainer &l)
 {
- for (LockedTransactionContainer::iterator i = l.begin(); i != l.end(); ++i) (*i)->unlock_tx();
+ for (LockedTransactionContainer::iterator i = l.begin(); i != l.end(); ++i) {
+ BOOST_ASSERT(*i!=0);
+
+ (*i)->unlock_tx();
+ }
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -1800,6 +1905,8 @@
       //-----------------------------------------------------------------------
       if (0 == i->second) continue;
 
+ BOOST_ASSERT(i->first!=0);
+
       if (using_move_semantics()) i->first->move_state(i->second);
       else i->first->copy_cache(*i->second);
       i->first->transaction_thread(invalid_thread_id());
@@ -1827,7 +1934,6 @@
 {
    for (WriteContainer::iterator i = writeList().begin(); writeList().end() != i; ++i)
    {
- //delete i->second; // delete all the temporary memory
       cache_release(i->second); // delete all the temporary memory
    }
 
@@ -1844,7 +1950,9 @@
    for (InflightTxes::iterator j = transactionsInFlight_.begin();
    j != transactionsInFlight_.end(); ++j)
    {
- transaction *t = (transaction*)*j;
+ BOOST_ASSERT(*j!=0);
+ (*j)->assert_tx_type();
+ transaction *t = *j;
       //-----------------------------------------------------------------------
       // since this is called while direct_writes are occurring, the transaction
       // calling it will be inflight, so we have to check for it and skip it
@@ -1928,8 +2036,6 @@
    for (MemoryContainerList::iterator i = newMemoryList().begin(); i != newMemoryList().end(); ++i)
    {
       detail::reset(*i);
- //(*i)->transaction_thread(invalid_thread_id());
- //(*i)->new_memory(0);
    }
 
    newMemoryList().clear();
@@ -1949,6 +2055,8 @@
       // memory is being destroyed, not updated. Do not perform copyState()
       // on it.
       //-----------------------------------------------------------------------
+ BOOST_ASSERT(i->first!=0);
+
       i->first->transaction_thread(invalid_thread_id());
       i->first->new_memory(0);
 
@@ -1981,6 +2089,8 @@
          continue;
       }
 
+ BOOST_ASSERT(i->first!=0);
+
       if (using_move_semantics()) i->first->move_state(i->second);
       else i->first->copy_cache(*i->second);
 
@@ -2003,6 +2113,8 @@
    // 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();
@@ -2018,6 +2130,8 @@
    // 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_)
       {
@@ -2036,7 +2150,9 @@
    for (InflightTxes::iterator j = transactionsInFlight_.begin();
    j != transactionsInFlight_.end(); ++j)
    {
- transaction *t = (transaction*)*j;
+ BOOST_ASSERT(*j!=0);
+ (*j)->assert_tx_type();
+ transaction *t = *j;
       //-----------------------------------------------------------------------
       // since this is called while direct_writes are occurring, the transaction
       // calling it will be inflight, so we have to check for it and skip it
@@ -2092,7 +2208,9 @@
    for (InflightTxes::iterator j = transactionsInFlight_.begin();
    j != transactionsInFlight_.end(); ++j)
    {
- transaction *t = (transaction*)*j;
+ BOOST_ASSERT(*j!=0);
+ (*j)->assert_tx_type();
+ transaction *t = *j;
       // if we're already aborting for this transaction, skip it
       if (t->forced_to_abort()) continue;
 
@@ -2188,6 +2306,8 @@
          for (std::list<transaction*>::iterator k = aborted.begin();
               k != aborted.end(); ++k)
          {
+ BOOST_ASSERT(*k!=0);
+
             (*k)->force_to_abort();
          }
 
@@ -2213,7 +2333,9 @@
    for (InflightTxes::iterator j = transactionsInFlight_.begin();
    j != transactionsInFlight_.end(); ++j)
    {
- transaction *t = (transaction*)*j;
+ BOOST_ASSERT(*j!=0);
+ (*j)->assert_tx_type();
+ transaction *t = *j;
       // if we're already aborting for this transaction, skip it
 #ifndef DISABLE_READ_SETS
       if (!t->isReading()) continue;
@@ -2262,6 +2384,8 @@
    // ok, forced to aborts are allowed, do them
    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_);
    }
@@ -2282,10 +2406,12 @@
    for (InflightTxes::iterator i = transactionsInFlight_.begin();
       i != transactionsInFlight_.end(); ++i)
    {
- if (((transaction*)*i) == this) continue;
- if (((transaction*)*i) == 0) continue;
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
+ if (*i == this) continue;
+ if (*i == 0) continue;
       // if this is not our threadId or this thread is not composable, skip it
- if (((transaction*)*i)->threadId_ != this->threadId_) continue;
+ if ((*i)->threadId_ != this->threadId_) continue;
       return true;
    }
 
@@ -2297,9 +2423,11 @@
    //////////////////////////////////////////////////////////////////////
    for (InflightTxes::iterator i = transactionsInFlight_.begin(); i != transactionsInFlight_.end(); ++i)
    {
+ BOOST_ASSERT(*i!=0);
+ (*i)->assert_tx_type();
       if (*i == rhs) continue;
       // if this is not our threadId or this thread is not composable, skip it
- if (((transaction*)*i)->threadId_ != this->threadId_) continue;
+ if ((*i)->threadId_ != this->threadId_) continue;
       return true;
    }
 

Modified: sandbox/stm/branches/vbe/boost/stm/exceptions.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/exceptions.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/exceptions.hpp 2010-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -17,6 +17,7 @@
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 #include <exception>
+#include <stdexcept>
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -27,19 +28,40 @@
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-class aborted_transaction_exception : public std::exception
+class aborted_transaction_exception
+ : public std::logic_error
 {
 public:
- aborted_transaction_exception(char const * const what) : what_(what) {}
+ aborted_transaction_exception(char const * const what)
+ : std::logic_error(what) {}
 
- //virtual char const * what() const { return what_; }
+};
+
+class aborted_transaction_exception_error
+ : public aborted_transaction_exception
+{
+public:
+ aborted_transaction_exception_error(char const * const what)
+ : aborted_transaction_exception(what) {}
 
-private:
- char const * const what_;
 };
 
 typedef aborted_transaction_exception aborted_tx;
 
+struct not_implemented
+ : public std::logic_error {
+ not_implemented(char const * const what)
+ : std::logic_error(what) {}
+
+};
+
+struct invalid_operation
+ : public std::logic_error {
+ invalid_operation(char const * const what)
+ : std::logic_error(what) {}
+
+};
+
 }}
 
 #endif // BOOST_STM_EXCEPTIONS__HPP

Modified: sandbox/stm/branches/vbe/boost/stm/language_like.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/language_like.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/language_like.hpp 2010-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -21,6 +21,7 @@
 #include <cstring>
 #include <iostream>
 #include <boost/assert.hpp>
+#include <exception>
 //---------------------------------------------------------------------------
 // helper function to implement macros
 namespace boost { namespace stm { namespace detail {
@@ -33,29 +34,30 @@
 
 struct commit_on_destruction {
     transaction* tx_;
- bool &stop_;
- bool &exception_catched_;
- bool commited_;
- commit_on_destruction(transaction& tx, bool &stop, bool& exception_catched)
- : tx_(&tx), stop_(stop), exception_catched_(exception_catched), commited_(false) {}
+ commit_on_destruction(transaction& tx)
+ : tx_(&tx) {}
 
     ~commit_on_destruction() {
         if (tx_!=0) {
- if(!commited_) {
+ if (!std::uncaught_exception()) {
                 try {
- tx_->commit();
- } catch (...) {
- exception_catched_=true;
+ commit();
+ //~ BOOST_STM_INFO;
+ } catch(...) {
+ BOOST_STM_INFO;
+ throw;
                 }
+ } else {
+ BOOST_STM_ERROR;
             }
- stop_ = tx_->committed();
- };
+ }
     }
 
     void commit() {
- if (tx_!=0&&!commited_) {
- tx_->commit();
- commited_=true;
+ if (tx_!=0) {
+ transaction* tmp=tx_;
+ tx_=0;
+ tmp->commit();
         }
     }
     void release() {
@@ -218,22 +220,6 @@
 // // or BOOST_STM_BEFORE_RETRY
 //---------------------------------------------------------------------------
 
-#define BOOST_STM_E_TRANSACTION \
-if (bool __boost_stm_stop_ = boost::stm::detail::no_opt_false()) {} else \
-{ \
- boost::stm::detail::control_flow __boost_stm_ctrl_; \
- do { \
- boost::stm::transaction __boost_stm_txn_; \
- try{ \
- bool __boost_stm_catched_=false; \
- { \
- boost::stm::detail::commit_on_destruction __boost_stm_destr_ (__boost_stm_txn_, __boost_stm_stop_, __boost_stm_catched_); \
- try{ \
- { \
- try { \
- if(false);else
-
-
 //~ __boost_stm_ctrl_: states if a specific control flow must be done
 //~ TX: the transaction
 //~ __boost_stm_catched_: variable
@@ -241,46 +227,43 @@
 // allow the user to compose exception handlers after his/her code
 // avoid the commit on destruction when an exception is thrown
 
-#define BOOST_STM_E_TRANSACTION_IN_LOOP \
-if (bool __boost_stm_stop_ = boost::stm::detail::no_opt_false()) {} else \
+//~ if (false) {} else
+
+
+#define BOOST_STM_E_TRANSACTION \
 { \
     boost::stm::detail::control_flow __boost_stm_ctrl_; \
- do { \
- boost::stm::transaction __boost_stm_txn_; \
- try { \
- bool __boost_stm_catched_=false; \
- { \
- boost::stm::detail::commit_on_destruction __boost_stm_destr_ (__boost_stm_txn_, __boost_stm_stop_, __boost_stm_catched_); \
- try { \
- do { \
- __boost_stm_ctrl_=boost::stm::detail::break_; \
- try { \
- if(false);else
+ for(boost::stm::transaction __boost_stm_txn_;;) { \
+ \
+ try{ \
+ boost::stm::detail::commit_on_destruction __boost_stm_destr_ (__boost_stm_txn_); \
+ try{ \
+ do { \
+ __boost_stm_ctrl_=boost::stm::detail::break_; \
+ if(false);else
 
                         // user code here
 
-#define BOOST_STM_E_ON_EXCEPTION \
- } \
- catch(boost::stm::detail::dummy_exception &ex) { throw; }
 
 #define BOOST_STM_E_RETRY \
- __boost_stm_ctrl_=boost::stm::detail::none; \
- break; \
- } while ((__boost_stm_ctrl_=boost::stm::detail::continue_),false); \
- __boost_stm_destr_.commit(); \
- } catch(...) { \
- __boost_stm_destr_.release(); \
- throw; \
- } \
- } \
- if (__boost_stm_catched_) { \
- throw boost::stm::aborted_tx("commit throw"); \
- } \
+ std::cout << __FILE__ << "["<<__LINE__<<"] end" << std::endl;\
+ __boost_stm_ctrl_=boost::stm::detail::none; \
+ break; \
+ } while ((__boost_stm_ctrl_=boost::stm::detail::continue_),false); \
+ } catch(...) { \
+ if (false)std::cout << __FILE__ << "["<<__LINE__<<"] catch1" << std::endl;\
+ __boost_stm_destr_.release(); \
+ throw; \
+ } \
             break; \
         } catch (boost::stm::aborted_tx &) { \
+ std::cout << __FILE__ << "["<<__LINE__<<"] catch2" << std::endl;\
             if (__boost_stm_txn_.is_nested()) throw; \
+ std::cout << __FILE__ << "["<<__LINE__<<"] catch3" << std::endl;\
             do { \
+ std::cout << __FILE__ << "["<<__LINE__<<"] catch4" << std::endl;\
                 __boost_stm_ctrl_=boost::stm::detail::break_; \
+ std::cout << __FILE__ << "["<<__LINE__<<"] catch5" << std::endl;\
                 try {throw;}catch (boost::stm::aborted_tx &)
 
 
@@ -288,42 +271,55 @@
                 __boost_stm_ctrl_=boost::stm::detail::none; \
                 break; \
             } while ((__boost_stm_ctrl_=boost::stm::detail::continue_),false); \
- BOOST_ASSERT(__boost_stm_ctrl_ == boost::stm::detail::none); \
- __boost_stm_txn_.restart(); \
         } \
- } while(!__boost_stm_stop_); \
-}
+ BOOST_ASSERT(__boost_stm_ctrl_ == boost::stm::detail::none); \
+ if (true) __boost_stm_txn_.restart(); \
+ } \
+ BOOST_ASSERT(__boost_stm_ctrl_ == boost::stm::detail::none); \
+} void()
 
 #define BOOST_STM_E_END_RETRY_IN_LOOP \
                 __boost_stm_ctrl_=boost::stm::detail::none; \
                 break; \
             } while ((__boost_stm_ctrl_=boost::stm::detail::continue_),false); \
- if (__boost_stm_ctrl_ != boost::stm::detail::none) break; \
- __boost_stm_txn_.restart(); \
         } \
- } while(!__boost_stm_stop_); \
+ if (__boost_stm_ctrl_ != boost::stm::detail::none) break; \
+ if (true) __boost_stm_txn_.restart(); \
+ } \
     if (__boost_stm_ctrl_==boost::stm::detail::continue_) continue; \
     if (__boost_stm_ctrl_==boost::stm::detail::break_) break; \
-}
+} void()
+
+
 
 #define BOOST_STM_E_END_TRANSACTION \
- BOOST_STM_E_ON_EXCEPTION \
  BOOST_STM_E_RETRY {} \
  BOOST_STM_E_END_RETRY
 
+#define BOOST_STM_E_TRANSACTION_IN_LOOP BOOST_STM_E_TRANSACTION
+
 #define BOOST_STM_E_END_TRANSACTION_IN_LOOP \
- BOOST_STM_E_ON_EXCEPTION \
  BOOST_STM_E_RETRY {} \
  BOOST_STM_E_END_RETRY_IN_LOOP
 
 #define BOOST_STM_E_BEFORE_RETRY BOOST_STM_E_RETRY
 
+#ifdef BOOST_STM_COMMITS_BEFORE_RETURN
 #define BOOST_STM_E_RETURN(EXPRESSION) \
     return boost::stm::detail::commit_and_return(__boost_stm_destr_, EXPRESSION)
 
 #define BOOST_STM_E_RETURN_NOTHING \
     if (!boost::stm::detail::commit_expr(__boost_stm_destr_));else return
 
+#else
+#define BOOST_STM_E_RETURN(EXPRESSION) \
+ return EXPRESSION
+
+#define BOOST_STM_E_RETURN_NOTHING \
+ return
+
+#endif
+
 //---------------------------------------------------------------------------
 // Catch a named abort exception leting the user to do somethink before retry
 //---------------------------------------------------------------------------
@@ -540,6 +536,45 @@
             PTR) \
     else delete [] PTR
 
+
+#define CATCH_AND_PRINT_ALL\
+ catch (int ex) { \
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
+ }\
+ catch (int& ex) { \
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
+ }\
+ catch (const char* ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
+ }\
+ catch (const char*& ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
+ }\
+ catch (std::string& ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
+ }\
+ catch (boost::synchro::lock_error& ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex.what() << std::endl;\
+ }\
+ catch (boost::synchro::timeout_exception& ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex.what() << std::endl;\
+ }\
+ catch (boost::stm::timer_lock_exception& ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex.what() << std::endl;\
+ }\
+ catch (boost::stm::aborted_tx& ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex.what() << std::endl;\
+ }\
+ catch (std::logic_error& ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex.what() << std::endl;\
+ }\
+ catch (std::exception& ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex.what() << std::endl;\
+ }\
+ catch (...) {\
+ std::cout << "*** ERROR: " <<__FILE__ << "["<<__LINE__<<"] catch UNKNOWN " << std::endl;\
+ }\
+
 ///////////////////////////////////////////////////////////////////////////////
 #endif // BOOST_STM_LANGUAGE_LIKE__HPP
 

Modified: sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp 2010-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -19,6 +19,7 @@
 #include <memory>
 //-----------------------------------------------------------------------------
 #include <boost/synchro.hpp>
+#include <boost/stm/trace.hpp>
 //-----------------------------------------------------------------------------
 #include <boost/stm/base_transaction_object.hpp>
 #include <boost/stm/cache_fct.hpp>
@@ -62,7 +63,12 @@
         , value_(ptr), ptr_(0) {}
 
     ~cache() {
- delete ptr_;
+ try {
+ delete ptr_;
+ } catch (...) {
+ BOOST_STM_ERROR;
+ }
+
     }
 
     inline T const * get() const {

Modified: sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp 2010-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -48,15 +48,11 @@
 
 //---------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-class timer_lock_exception : public std::exception
+class timer_lock_exception : public std::logic_error
 {
 public:
- timer_lock_exception(char const * const what) : what_(what) {}
+ timer_lock_exception(char const * const what) : std::logic_error(what) {}
 
- //virtual char const * what() const { return what_; }
-
-private:
- char const * const what_;
 };
 
 
@@ -98,7 +94,13 @@
       do_timed_auto_lock(timeOut);
    }
 
- ~auto_lock() { do_auto_unlock(); }
+ ~auto_lock() {
+ try {
+ do_auto_unlock();
+ } catch (...) {
+ BOOST_STM_ERROR;
+ }
+ }
 
    bool has_lock() { return hasLock_; }
 

Modified: sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/lock_guard.hpp 2010-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -39,7 +39,11 @@
         explicit static_lock_guard(adopt_lock_t)
         {}
         ~static_lock_guard() {
- unlock(m);
+ try {
+ unlock(m);
+ } catch (...) {
+ BOOST_STM_ERROR;
+ }
         }
     };
 #endif
@@ -62,7 +66,11 @@
             : m(m_)
         {}
         ~lock_guard() {
- m.unlock();
+ try {
+ m.unlock();
+ } catch (...) {
+ BOOST_STM_ERROR;
+ }
         }
     };
 
@@ -84,7 +92,11 @@
             : cnd_(cnd)
         {}
         ~static_lock_guard_if() {
- if (cnd_) unlock(m);
+ try {
+ if (cnd_) unlock(m);
+ } catch (...) {
+ BOOST_STM_ERROR;
+ }
         }
     };
 
@@ -108,7 +120,11 @@
             , cnd_(cnd)
         {}
         ~lock_guard_if() {
- if (cnd_) unlock(m);
+ try {
+ if (cnd_) unlock(m);
+ } catch (...) {
+ BOOST_STM_ERROR;
+ }
         }
     };
 #endif

Modified: sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/unique_lock.hpp 2010-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -137,10 +137,15 @@
 #endif
         ~unique_lock()
         {
- if(owns_lock())
- {
- m->unlock();
+ try {
+ if(owns_lock())
+ {
+ m->unlock();
+ }
+ } catch (...) {
+ BOOST_STM_ERROR;
             }
+
         }
         void lock()
         {
@@ -155,7 +160,7 @@
         {
             if(owns_lock())
             {
- throw lock_error();
+ throw synchro::lock_error();
             }
             is_locked=m->try_lock();
             return is_locked;

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-02-25 12:14:46 EST (Thu, 25 Feb 2010)
@@ -26,6 +26,7 @@
 #include <string>
 #include <vector>
 //-----------------------------------------------------------------------------
+#include <boost/stm/trace.hpp>
 #include <boost/synchro/tss.hpp>
 //-----------------------------------------------------------------------------
 #include <boost/stm/detail/config.hpp>
@@ -241,7 +242,7 @@
    inline static void enable_move_semantics()
    {
       if (!kDracoMoveSemanticsCompiled)
- throw "move semantics off - rebuild with #define BUILD_MOVE_SEMANTICS 1";
+ throw not_implemented("move semantics off - rebuild with #define BUILD_MOVE_SEMANTICS 1");
       usingMoveSemantics_ = true;
    }
 
@@ -386,8 +387,9 @@
 
    bool is_nested() const
    {
- synchro::lock_guard<Mutex> lock_m(*inflight_lock());
- return other_in_flight_same_thread_transactions();
+ return nested_;
+ //~ synchro::lock_guard<Mutex> lock_m(*inflight_lock());
+ //~ return other_in_flight_same_thread_transactions();
    }
 
    bool check_throw_before_restart() const
@@ -404,7 +406,7 @@
       synchro::lock_guard<Mutex> lock_m(*inflight_lock());
       if (other_in_flight_same_thread_transactions())
       {
- throw aborted_transaction_exception("closed nesting throw");
+ throw aborted_transaction_exception("closed nesting throws");
       }
 
       return true;
@@ -427,8 +429,6 @@
       if (1 == in.new_memory()) return in;
       if (in.transaction_thread() == invalid_thread_id()) return in;
 
- //base_transaction_object *inPtr = (base_transaction_object*)&in;
-
       for (WriteContainer::iterator i = writeList().begin(); i != writeList().end(); ++i)
       {
          if (i->second == &in)
@@ -560,7 +560,7 @@
       if (direct_updating())
       {
 #if PERFORMING_VALIDATION
- throw "direct updating not implemented for validation yet";
+ throw not_implemented("direct updating not implemented for validation yet");
 #else
          return direct_read(in);
 #endif
@@ -608,7 +608,7 @@
       if (direct_updating())
       {
 #if PERFORMING_VALIDATION
- throw "direct updating not implemented for validation yet";
+ throw not_implemented("direct updating not implemented for validation yet");
 #else
          return direct_write<T,Poly>(in);
 #endif
@@ -626,7 +626,7 @@
       if (direct_updating())
       {
 #if PERFORMING_VALIDATION
- throw "direct updating not implemented for validation yet";
+ throw ("direct updating not implemented for validation yet");
 #else
          direct_delete_memory(in);
 #endif
@@ -649,7 +649,7 @@
       if (direct_updating())
       {
 #if PERFORMING_VALIDATION
- throw "direct updating not implemented for validation yet";
+ throw ("direct updating not implemented for validation yet");
 #else
          direct_delete_non_tx_ptr(in);
 #endif
@@ -681,7 +681,7 @@
       if (direct_updating())
       {
 #if PERFORMING_VALIDATION
- throw "direct updating not implemented for validation yet";
+ throw ("direct updating not implemented for validation yet");
 #else
          direct_delete_tx_array(in, size);
 #endif
@@ -697,7 +697,7 @@
       if (direct_updating())
       {
 #if PERFORMING_VALIDATION
- throw "direct updating not implemented for validation yet";
+ throw ("direct updating not implemented for validation yet");
 #else
          direct_delete_tx_array(in, size);
 #endif
@@ -867,7 +867,9 @@
       for (InflightTxes::iterator j = transactionsInFlight_.begin();
       j != transactionsInFlight_.end(); ++j)
       {
- //~ transaction *t = (transaction*)*j;
+ BOOST_ASSERT(*j!=0);
+
+ (*j)->assert_tx_type();
          transaction *t = *j;
 
          // if this is a parent or child tx, it must abort too
@@ -895,10 +897,11 @@
 
    inline static InflightTxes const & in_flight_transactions() { return transactionsInFlight_; }
 
- void make_irrevocable();
- void make_isolated();
- bool irrevocable() const;
- bool isolated() const;
+ inline void make_irrevocable();
+ 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_; }
 
@@ -949,7 +952,6 @@
       // otherwise, see if its in our read list
       //--------------------------------------------------------------------
 #ifndef DISABLE_READ_SETS
- //~ ReadContainer::iterator i = readList().find((base_transaction_object*)&in);
       ReadContainer::iterator i = readList().find(&in);
       if (i != readList().end()) return in;
 #endif
@@ -980,7 +982,6 @@
             //stm::lock(m);
 
             WriteContainer* c = write_lists(in.transaction_thread());
- //~ WriteContainer::iterator readMem = c->find((base_transaction_object*)&in);
             WriteContainer::iterator readMem = c->find(const_cast<T*>(&in));
             if (readMem == c->end())
             {
@@ -988,7 +989,6 @@
             }
 
 #ifndef DISABLE_READ_SETS
- //~ readList().insert((base_transaction_object*)readMem->second);
             readList().insert(readMem->second);
 #endif
 #if USE_BLOOM_FILTER
@@ -1002,7 +1002,6 @@
 
          // already have locked us above - in both if / else
 #ifndef DISABLE_READ_SETS
- //~ readList().insert((base_transaction_object*)&in);
          readList().insert(&in);
 #endif
 #if USE_BLOOM_FILTER
@@ -1028,7 +1027,6 @@
          //lock_tx();
          // already have locked us above - in both if / else
 #ifndef DISABLE_READ_SETS
- //~ readList().insert((base_transaction_object*)&in);
          readList().insert(&in);
 #endif
 #if USE_BLOOM_FILTER
@@ -1068,7 +1066,6 @@
       }
 
       in.transaction_thread(threadId_);
- //~ writeList().insert(tx_pair((base_transaction_object*)&in, detail::make_cache_aux<Poly>::apply(in , *this)));
       writeList().insert(tx_pair(&in, detail::make_cache_aux<Poly>::apply(in , *this)));
 #if USE_BLOOM_FILTER
       bloom().insert((std::size_t)&in);
@@ -1103,7 +1100,7 @@
          lock_m.unlock();
          // is this really necessary? in the deferred case it is, but in direct it
          // doesn't actually save any time for anything
- //writeList()[(base_transaction_object*)&in] = 0;
+ //writeList()[&in] = 0;
 
          deletedMemoryList().push_back(detail::make(in));
       }
@@ -1136,7 +1133,7 @@
          lock_m.unlock();
          // is this really necessary? in the deferred case it is, but in direct it
          // doesn't actually save any time for anything
- //writeList()[(base_transaction_object*)&in] = 0;
+ //writeList()[&in] = 0;
 
          deletedMemoryList().push_back(detail::make_non_tx(in));
       }
@@ -1249,7 +1246,7 @@
             lock_m.unlock();
             // is this really necessary? in the deferred case it is, but in direct it
             // doesn't actually save any time for anything
- //writeList()[(base_transaction_object*)&in] = 0;
+ //writeList()[&in] = 0;
 
             deletedMemoryList().push_back(detail::make_array(in, size));
         }
@@ -1281,8 +1278,6 @@
       if (writeList().empty()) return insert_and_return_read_memory(in);
 #endif
 
- //~ WriteContainer::iterator i = writeList().find
- //~ ((base_transaction_object*)(&in));
       WriteContainer::iterator i = writeList().find(const_cast<T*>(&in));
       //----------------------------------------------------------------
       // always check to see if read memory is in write list since it is
@@ -1312,10 +1307,8 @@
       //lock_tx();
 #ifndef DISABLE_READ_SETS
 #if PERFORMING_VALIDATION
- //~ readList()[(base_transaction_object*)&in] = in.version_;
       readList()[&in] = in.version_;
 #else
- //~ readList().insert((base_transaction_object*)&in);
       readList().insert(&in);
 #endif
 #endif
@@ -1407,7 +1400,6 @@
          // second location. If it's there, it means we made a copy of a piece
          for (WriteContainer::iterator j = writeList().begin(); writeList().end() != j; ++j)
          {
- //~ if (j->second == (base_transaction_object*)&in)
             if (j->second == &in)
             {
                writeList().insert(tx_pair(j->first, 0));
@@ -1438,7 +1430,7 @@
       // synchro::lock_guard<Mutex> lock(*mutex());
       // bloom().insert((std::size_t)&in);
       // }
- // writeList().insert(tx_pair((base_transaction_object*)&in, 0));
+ // writeList().insert(tx_pair(&in, 0));
       //}
       //-----------------------------------------------------------------------
       // this isn't real memory, it's transactional memory. But the good news is,
@@ -1455,7 +1447,7 @@
       // // second location. If it's there, it means we made a copy of a piece
       // for (WriteContainer::iterator j = writeList().begin(); writeList().end() != j; ++j)
       // {
- // if (j->second == (base_transaction_object*)&in)
+ // if (j->second == &in)
       // {
       // writeList().insert(tx_pair(j->first, 0));
       // deletedMemoryList().push_back(detail::make(j->first));
@@ -1521,7 +1513,6 @@
                 }
             }
             for (int i=size-1; i>=0; --i) {
- //~ writeList().insert(tx_pair((base_transaction_object*)(&in[i]), 0));
                 writeList().insert(tx_pair(&in[i], 0));
             }
         }
@@ -1543,7 +1534,6 @@
             for (int i=size-1; i>=0; --i)
             for (WriteContainer::iterator j = writeList().begin(); writeList().end() != j; ++j)
             {
- //~ if (j->second == (base_transaction_object*)(&in[i]))
                 if (j->second == &in[i])
                 {
                     writeList().insert(tx_pair(j->first, 0));
@@ -2319,6 +2309,7 @@
    transaction_state state_; // 2bits
    std::size_t reads_;
    mutable clock_t startTime_;
+ bool nested_;
 
    inline transaction_state const & state() const { return state_; }
 


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