Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56726 - in sandbox/stm/branches/vbe: boost/stm boost/stm/detail boost/stm/non_tx/detail boost/stm/tx libs/stm/example libs/stm/src
From: vicente.botet_at_[hidden]
Date: 2009-10-11 18:14:02


Author: viboes
Date: 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
New Revision: 56726
URL: http://svn.boost.org/trac/boost/changeset/56726

Log:
TBoost.Stm vbe
* unused files cleanup
* cache_map coding
* current_transaction improvements
* transactional_object improvements
* upgrd_ptr improvements
Removed:
   sandbox/stm/branches/vbe/boost/stm/detail/except_and_back_off_on_abort_notice_cm_i_impl.hpp
   sandbox/stm/branches/vbe/boost/stm/detail/except_and_back_off_on_abort_notice_cm_impl.hpp
   sandbox/stm/branches/vbe/boost/stm/detail/tx_ptr.hpp
   sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm.hpp
   sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm_i.hpp
   sandbox/stm/branches/vbe/boost/stm/tx_smart_ptr.hpp
Text files modified:
   sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 5 ++-
   sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp | 18 ++++++------
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 21 +++++++++------
   sandbox/stm/branches/vbe/boost/stm/transactional_object.hpp | 16 ++++++------
   sandbox/stm/branches/vbe/boost/stm/tx/numeric.hpp | 11 ++++++-
   sandbox/stm/branches/vbe/boost/stm/tx/smart_ptr.hpp | 16 +++++++++++
   sandbox/stm/branches/vbe/libs/stm/example/list.cpp | 53 ++++++++++++++++++++++++++++-----------
   sandbox/stm/branches/vbe/libs/stm/example/non_tx_counter.cpp | 8 ++---
   sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp | 2 +
   9 files changed, 100 insertions(+), 50 deletions(-)

Modified: sandbox/stm/branches/vbe/boost/stm/detail/config.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/config.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/config.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
@@ -28,13 +28,13 @@
 //#define LOGGING_BLOCKS 1
 
 ///////////////////////////////////////////////////////////////////////////////
-// The cache an be structured in different ways. Define ony one of
+// The cache can be structured in different ways. Define ony one of
 // USE_SINGLE_THREAD_CONTEXT_MAP: use of a common tx_context as TSS
 // BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP: use of common tss_context as TSS
 // 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
 
 ///////////////////////////////////////////////////////////////////////////////
 // When USE_SINGLE_THREAD_CONTEXT_MAP or BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP are defined you can want to store references to the TSS or not
@@ -64,6 +64,7 @@
 //// BOOST_STM_CACHE_USE_MEMORY_MANAGER: uses the class specific memory manager
 //// BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER: uses the monotonic storage memory manager
 
+
 #define BOOST_STM_CACHE_USE_MALLOC 1
 //#define BOOST_STM_CACHE_USE_MEMORY_MANAGER 1
 //#define BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER 1

Deleted: sandbox/stm/branches/vbe/boost/stm/detail/except_and_back_off_on_abort_notice_cm_i_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/except_and_back_off_on_abort_notice_cm_i_impl.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
+++ (empty file)
@@ -1,121 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Justin E. Gottchlich 2009.
-// (C) Copyright Vicente J. Botet Escriba 2009.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/stm for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-
-#include <boost/stm/transaction.hpp>
-#include <boost/stm/except_and_back_off_on_abort_notice_cm.hpp>
-
-namespace boost { namespace stm {
-
-
-inline void except_and_back_off_on_abort_notice_cm::abort_on_write
-(transaction &t, base_transaction_object const &in)
-{
- //SLEEP(initialSleepTime_);
- t.lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
-}
-
-/////////////////////////////////////////////////////////////////////////
-inline void except_and_back_off_on_abort_notice_cm::abort_on_read
-(transaction const &constT, base_transaction_object const &in)
-{
- transaction &t = const_cast<transaction&>(constT);
-
- //SLEEP(initialSleepTime_);
- t.lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
-}
-
-/////////////////////////////////////////////////////////////////////////
-inline void except_and_back_off_on_abort_notice_cm::abort_on_delete
-(transaction const &constT, base_transaction_object const &in)
-{
- transaction &t = const_cast<transaction&>(constT);
-
- //SLEEP(initialSleepTime_);
- t.lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
-}
-
-/////////////////////////////////////////////////////////////////////////
-inline void except_and_back_off_on_abort_notice_cm::abort_on_new(transaction const &constT)
-{
- transaction &t = const_cast<transaction&>(constT);
-
- //SLEEP(initialSleepTime_);
- t.lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
-}
-
- ////////////////////////////////////////////////////////////////////////////
- inline void except_and_back_off_on_abort_notice_cm::perform_isolated_tx_wait_priority_promotion(transaction &lhs)
- {
- lhs.raise_priority();
- }
-
- ////////////////////////////////////////////////////////////////////////////
- inline void except_and_back_off_on_abort_notice_cm::perform_irrevocable_tx_wait_priority_promotion(transaction &lhs)
- {
- lhs.raise_priority();
- }
-
- //--------------------------------------------------------------------------
- // this code is only ever called if "validation" is on not "invalidation"
- // so don't worry about this code EVER stopping invalidation from committing
- //--------------------------------------------------------------------------
- inline bool except_and_back_off_on_abort_notice_cm::abort_before_commit(transaction const &t)
- {
- using namespace boost::stm;
-
- for (transaction::in_flight_trans_cont::const_iterator i =
- transaction::in_flight_transactions().begin();
- i != transaction::in_flight_transactions().end(); ++i)
- {
- if (t.priority() < (*i)->priority()) return true;
- }
-
- return false;
- }
-
- inline bool except_and_back_off_on_abort_notice_cm::permission_to_abort
- (transaction const &lhs, transaction const &rhs)
- {
- return true;
-#if 0
- if (lhs.priority() + 100 > rhs.priority()) return true;
-
- rhs.set_priority(rhs.priority() + 1000);
- return false;
-#endif
- //return lhs.writes() * lhs.priority() >= rhs.writes() * rhs.priority();
- //return lhs.writes() + lhs.reads() >= rhs.writes() + rhs.reads();
- }
-
- inline bool except_and_back_off_on_abort_notice_cm::allow_lock_to_abort_tx
- (int const & lockWaitTime, int const &lockAborted, bool txTryingToAbortIsIrrevocable, transaction const &rhs)
- {
- if (txTryingToAbortIsIrrevocable) return true;
-
-#ifndef DISABLE_READ_SETS
- if ((size_t)lockWaitTime > rhs.read_set_size() + 100 * rhs.writes())
-#else
- if ((size_t)lockWaitTime > 100 * rhs.writes())
-#endif
- {
- return true;
- }
- else return false;
- }
-
-}}

Deleted: sandbox/stm/branches/vbe/boost/stm/detail/except_and_back_off_on_abort_notice_cm_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/except_and_back_off_on_abort_notice_cm_impl.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
+++ (empty file)
@@ -1,121 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Justin E. Gottchlich 2009.
-// (C) Copyright Vicente J. Botet Escriba 2009.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/stm for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-
-#include <boost/stm/transaction.hpp>
-#include <boost/stm/except_and_back_off_on_abort_notice_cm.hpp>
-
-namespace boost { namespace stm {
-
-
-inline void except_and_back_off_on_abort_notice_cm::abort_on_write
-(transaction &t, base_transaction_object const &in)
-{
- //SLEEP(initialSleepTime_);
- t.lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
-}
-
-/////////////////////////////////////////////////////////////////////////
-inline void except_and_back_off_on_abort_notice_cm::abort_on_read
-(transaction const &constT, base_transaction_object const &in)
-{
- transaction &t = const_cast<transaction&>(constT);
-
- //SLEEP(initialSleepTime_);
- t.lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
-}
-
-/////////////////////////////////////////////////////////////////////////
-inline void except_and_back_off_on_abort_notice_cm::abort_on_delete
-(transaction const &constT, base_transaction_object const &in)
-{
- transaction &t = const_cast<transaction&>(constT);
-
- //SLEEP(initialSleepTime_);
- t.lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
-}
-
-/////////////////////////////////////////////////////////////////////////
-inline void except_and_back_off_on_abort_notice_cm::abort_on_new(transaction const &constT)
-{
- transaction &t = const_cast<transaction&>(constT);
-
- //SLEEP(initialSleepTime_);
- t.lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
-}
-
- ////////////////////////////////////////////////////////////////////////////
- inline void except_and_back_off_on_abort_notice_cm::perform_isolated_tx_wait_priority_promotion(transaction &lhs)
- {
- lhs.raise_priority();
- }
-
- ////////////////////////////////////////////////////////////////////////////
- inline void except_and_back_off_on_abort_notice_cm::perform_irrevocable_tx_wait_priority_promotion(transaction &lhs)
- {
- lhs.raise_priority();
- }
-
- //--------------------------------------------------------------------------
- // this code is only ever called if "validation" is on not "invalidation"
- // so don't worry about this code EVER stopping invalidation from committing
- //--------------------------------------------------------------------------
- inline bool except_and_back_off_on_abort_notice_cm::abort_before_commit(transaction const &t)
- {
- using namespace boost::stm;
-
- for (transaction::in_flight_trans_cont::const_iterator i =
- transaction::in_flight_transactions().begin();
- i != transaction::in_flight_transactions().end(); ++i)
- {
- if (t.priority() < (*i)->priority()) return true;
- }
-
- return false;
- }
-
- inline bool except_and_back_off_on_abort_notice_cm::permission_to_abort
- (transaction const &lhs, transaction const &rhs)
- {
- return true;
-#if 0
- if (lhs.priority() + 100 > rhs.priority()) return true;
-
- rhs.set_priority(rhs.priority() + 1000);
- return false;
-#endif
- //return lhs.writes() * lhs.priority() >= rhs.writes() * rhs.priority();
- //return lhs.writes() + lhs.reads() >= rhs.writes() + rhs.reads();
- }
-
- inline bool except_and_back_off_on_abort_notice_cm::allow_lock_to_abort_tx
- (int const & lockWaitTime, int const &lockAborted, bool txTryingToAbortIsIrrevocable, transaction const &rhs)
- {
- if (txTryingToAbortIsIrrevocable) return true;
-
-#ifndef DISABLE_READ_SETS
- if ((size_t)lockWaitTime > rhs.read_set_size() + 100 * rhs.writes())
-#else
- if ((size_t)lockWaitTime > 100 * rhs.writes())
-#endif
- {
- return true;
- }
- else return false;
- }
-
-}}

Deleted: sandbox/stm/branches/vbe/boost/stm/detail/tx_ptr.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/tx_ptr.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
+++ (empty file)
@@ -1,14 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Justin E. Gottchlich 2009.
-// (C) Copyright Vicente J. Botet Escriba 2009.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/stm for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/stm/tx_ptr.hpp>

Deleted: sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
+++ (empty file)
@@ -1,78 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Justin E. Gottchlich 2009.
-// (C) Copyright Vicente J. Botet Escriba 2009.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/stm for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef BOOST_STM_EXCEPT_AND_BACK_OFF_ABORT_NOTICE_CM_H
-#define BOOST_STM_EXCEPT_AND_BACK_OFF_ABORT_NOTICE_CM_H
-
-namespace boost { namespace stm {
- class transaction;
-
-////////////////////////////////////////////////////////////////////////////
-//
-// this class backs off (and sleeps) when aborting. this is commonly known
-// as "exponential backoff" for locking mechanisms.
-//
-////////////////////////////////////////////////////////////////////////////
-class except_and_back_off_on_abort_notice_cm //: public base_contention_manager
-{
-public:
-
-#if 0
- static void init(int const initialSleepTime, int const sleepIncrease,
- int const maxIncreases)
- {
- sleepTime_=initialSleepTime;
- kSleepFactorIncrease_=sleepIncrease;
- kMaxIncreases_=maxIncreases;
- initialSleepTime_=initialSleepTime;
- kMaxSleepTime_ = kSleepFactorIncrease_ * sleepTime_ * kMaxIncreases_;
- }
-#endif
- ////////////////////////////////////////////////////////////////////////////
- static void abort_on_write(transaction &t,
- base_transaction_object const &in);
- static void abort_on_read(transaction const &t,
- base_transaction_object const &in);
- static void abort_on_delete(transaction const &t,
- base_transaction_object const &in);
- static void abort_on_new(transaction const &t);
-
- ////////////////////////////////////////////////////////////////////////////
- static void perform_isolated_tx_wait_priority_promotion(transaction &lhs);
-
- ////////////////////////////////////////////////////////////////////////////
- static void perform_irrevocable_tx_wait_priority_promotion(transaction &lhs);
- static int lock_sleep_time() { return 10; }
-
- //--------------------------------------------------------------------------
- // this code is only ever called if "validation" is on not "invalidation"
- // so don't worry about this code EVER stopping invalidation from committing
- //--------------------------------------------------------------------------
- static bool abort_before_commit(transaction const &t);
-
- static bool permission_to_abort(transaction const &lhs, transaction const &rhs);
-
- static bool allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
- bool txTryingToAbortIsIrrevocable, transaction const &rhs);
-
-//private:
-
- static int sleepTime_;
- static int const kSleepFactorIncrease_;
- static int kMaxSleepTime_;
- static int const kMaxIncreases_;
- static int const initialSleepTime_;
-};
-
-}}
-#endif

Deleted: sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm_i.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm_i.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
+++ (empty file)
@@ -1,75 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Justin E. Gottchlich 2009.
-// (C) Copyright Vicente J. Botet Escriba 2009.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/stm for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef BOOST_STM_EXCEPT_AND_BACK_OFF_ABORT_NOTICE_CM_H
-#define BOOST_STM_EXCEPT_AND_BACK_OFF_ABORT_NOTICE_CM_H
-
-namespace boost { namespace stm {
- class transaction;
-
-////////////////////////////////////////////////////////////////////////////
-//
-// this class backs off (and sleeps) when aborting. this is commonly known
-// as "exponential backoff" for locking mechanisms.
-//
-////////////////////////////////////////////////////////////////////////////
-class except_and_back_off_on_abort_notice_cm //: public base_contention_manager
-{
-public:
-
- except_and_back_off_on_abort_notice_cm(int const initialSleepTime, int const sleepIncrease,
- int const maxIncreases)
- : sleepTime_(initialSleepTime), kSleepFactorIncrease_(sleepIncrease),
- kMaxIncreases_(maxIncreases), initialSleepTime_(initialSleepTime)
- {
- kMaxSleepTime_ = kSleepFactorIncrease_ * sleepTime_ * kMaxIncreases_;
- }
-
- ////////////////////////////////////////////////////////////////////////////
- inline void abort_on_write(transaction &t,
- base_transaction_object const &in);
- inline void abort_on_read(transaction const &t,
- base_transaction_object const &in);
- inline void abort_on_delete(transaction const &t,
- base_transaction_object const &in);
- inline void abort_on_new(transaction const &t);
-
- ////////////////////////////////////////////////////////////////////////////
- inline void perform_isolated_tx_wait_priority_promotion(transaction &lhs);
-
- ////////////////////////////////////////////////////////////////////////////
- inline void perform_irrevocable_tx_wait_priority_promotion(transaction &lhs);
- inline int lock_sleep_time() { return 10; }
-
- //--------------------------------------------------------------------------
- // this code is only ever called if "validation" is on not "invalidation"
- // so don't worry about this code EVER stopping invalidation from committing
- //--------------------------------------------------------------------------
- inline bool abort_before_commit(transaction const &t);
-
- inline bool permission_to_abort(transaction const &lhs, transaction const &rhs);
-
- inline bool allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
- bool txTryingToAbortIsIrrevocable, transaction const &rhs);
-
-private:
-
- int sleepTime_;
- int const kSleepFactorIncrease_;
- int kMaxSleepTime_;
- int const kMaxIncreases_;
- int const initialSleepTime_;
-};
-
-}}
-#endif

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 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
@@ -59,27 +59,27 @@
         return ptr_;
     }
     virtual base_transaction_object* clone() const {
- cache* tmp = cache_clone(*this);
+ cache* tmp = new cache<T>(*this);
         if (tmp->value_!=0) {
             tmp->ptr_ = new T(*value_);
         }
         return tmp;
     }
 
- virtual void copy_state(base_transaction_object const * const rhs) {
- if (value_==0) return;
- *value_= *(static_cast<cache<T> const * const>(rhs)->ptr_);
+#ifdef BOOST_STM_USE_MEMCOPY
+ virtual void cache_deallocate() {
         delete ptr_;
         ptr_=0;
+ delete this;
     }
+#endif
 
-#ifdef BOOST_STM_USE_MEMCOPY
- virtual void cache_deallocate() {
+ virtual void copy_state(base_transaction_object const * const rhs) {
+ if (value_==0) return;
+ *value_= *(static_cast<cache<T> const * const>(rhs)->ptr_);
         delete ptr_;
         ptr_=0;
- boost::stm::cache_deallocate(this);
     }
-#endif
 
 #if USE_STM_MEMORY_MANAGER
    void* operator new(size_t size) throw ()
@@ -89,7 +89,7 @@
 
    void operator delete(void* mem)
    {
- return_mem(mem, sizeof(transactional_object<T>));
+ return_mem(mem, sizeof(cache<T>));
    }
 #endif
 

Modified: sandbox/stm/branches/vbe/boost/stm/transaction.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/transaction.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/transaction.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
@@ -198,7 +198,7 @@
     {
         inline tss_context()
         : tx_()
- , transactions()
+ , transactions_()
         #ifndef BOOST_STM_USE_BOOST_MUTEX
         #if WIN32
         , mutex_(PTHREAD_MUTEX_INITIALIZER)
@@ -212,7 +212,8 @@
         #endif
         {
             // the current transaction is 0
- transactions.push(0);
+ //transactions_.push(static_cast<transaction*>(0));
+ transactions_.push(0);
             #ifndef BOOST_STM_USE_BOOST_MUTEX
             pthread_mutex_init(&mutex_, 0);
             #endif
@@ -222,7 +223,7 @@
         }
 
         tx_context tx_;
- TransactionStack transactions;
+ TransactionsStack transactions_;
         Mutex mutex_;
         #if PERFORMING_LATM
         int blocked_;
@@ -1632,8 +1633,7 @@
     inline static TransactionsStack &transactions(thread_id_t id) {
         return *threadTransactionsStack_.find(id)->second;
     }
- private:
-
+ private:
 
 ////////////////////////////////////////
 #else //BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
@@ -1791,11 +1791,16 @@
         return i->second->currentlyLockedLocks_;
     }
 #endif
- inline TransactionsStack &transactions() {return context_.transactions_;}
+
+ TransactionsStack& transactionsRef_;
+ public:
+ inline TransactionsStack& transactions() {return transactionsRef_;}
     inline static TransactionsStack &transactions(thread_id_t id) {
         tss_context_map_type::iterator i = tss_context_map_.find(id);
         return i->second->transactions_;
     }
+ private:
+
 #endif
 
 
@@ -1936,7 +1941,7 @@
    inline static MutexSet &currentlyLockedLocksRef(thread_id_t id) {return *threadCurrentlyLockedLocks_.find(id)->second;}
 #endif
 
- static ThreadTransactionsStack threadTransactionsStack_;
+ //static ThreadTransactionsStack threadTransactionsStack_;
     TransactionsStack& transactionsRef_;
    public:
     inline TransactionsStack& transactions() {return transactionsRef_;}
@@ -2189,7 +2194,7 @@
 #include <boost/stm/detail/transaction_impl.hpp>
 #include <boost/stm/detail/latm_general_impl.hpp>
 #include <boost/stm/detail/auto_lock.hpp>
-#include <boost/stm/detail/tx_ptr.hpp>
+#include <boost/stm/tx_ptr.hpp>
 
 #if defined(BOOST_STM_CM_STATIC_CONF)
 #if defined(BOOST_STM_CM_STATIC_CONF_ExceptAndBackOffOnAbortNoticeCM)

Modified: sandbox/stm/branches/vbe/boost/stm/transactional_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/transactional_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/transactional_object.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
@@ -72,21 +72,21 @@
     }
 
     virtual base_transaction_object* clone() const {
- return cache_clone(*this);
- }
-
- virtual void copy_state(base_transaction_object const * const rhs) {
- cache_copy(static_cast<transactional_object<T> const * const>(rhs),
- //static_cast<transactional_object<T> *>(this));
- this);
+ return new transactional_object<T>(*this);
     }
 
 #ifdef BOOST_STM_USE_MEMCOPY
     virtual void cache_deallocate() {
- boost::stm::cache_deallocate(this);
+ //boost::stm::cache_deallocate(this);
+ delete this;
     }
 #endif
 
+ virtual void copy_state(base_transaction_object const * const rhs) {
+ //cache_copy(static_cast<transactional_object<T> const * const>(rhs), this);
+ *this=*static_cast<transactional_object<T> const * const>(rhs);
+ }
+
 #if USE_STM_MEMORY_MANAGER
    void* operator new(size_t size) throw ()
    {

Modified: sandbox/stm/branches/vbe/boost/stm/tx/numeric.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/numeric.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/numeric.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
@@ -17,7 +17,7 @@
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 #include <boost/stm/transaction.hpp>
-#include <boost/stm/non_tx/detail/cache_map.hpp>
+//#include <boost/stm/non_tx/detail/cache_map.hpp>
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -39,9 +39,16 @@
     // contructor from a implicitly convertible to T
     template <typename U>
     numeric(U v) : val_(v) {}
- //
+ //numeric(T v) : val_(v) {}
     ~numeric() {}
 
+ #if 0
+ template<class U>
+ numeric& operator=(numeric<U> const& r) {
+ val_=r.value();
+ }
+ #endif
+
     operator T() const { return value(); }
     operator T&() { return ref(); }
 

Modified: sandbox/stm/branches/vbe/boost/stm/tx/smart_ptr.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/smart_ptr.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/smart_ptr.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
@@ -407,7 +407,13 @@
     mutable bool written_;
 
     inline upgrd_ptr(transaction &t, tx_ptr<T> tx_obj) : tx_(&t),
- ptr_(const_cast<transactional_object<T>*>(t.read_ptr(tx_obj.ptr_))), written_(false) {}
+ ptr_(const_cast<transactional_object<T>*>(t.read_ptr(tx_obj.ptr_))), written_(false) {
+ std::cout << __LINE__ << " ptr_ " << ptr_ << std::endl;
+ if (ptr_!=0) {
+ std::cout << __LINE__ << " ptr_->value" << ptr_->value << std::endl;
+ std::cout << __LINE__ << " &ptr_->value" << &ptr_->value << std::endl;
+ }
+ }
 
     template<class Y>
     upgrd_ptr & operator=(tx_ptr<Y> const& r) { // never throws
@@ -421,6 +427,8 @@
     }
 
     const T* get() const {
+ std::cout << __LINE__ << " ptr_" << ptr_ << std::endl;
+ if (ptr_==0) return 0;
         if (tx_->forced_to_abort()) {
             tx_->lock_and_abort();
             throw aborted_transaction_exception("aborting transaction");
@@ -438,6 +446,12 @@
             }
         }
 
+ std::cout << __LINE__ << " ptr_" << ptr_ << std::endl;
+ if (ptr_!=0) {
+ std::cout << __LINE__ << " ptr_->value" << ptr_->value << std::endl;
+ std::cout << __LINE__ << " &ptr_->value" << &ptr_->value << std::endl;
+ }
+ if (ptr_==0) return 0;
         return &ptr_->value;
     }
 

Deleted: sandbox/stm/branches/vbe/boost/stm/tx_smart_ptr.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx_smart_ptr.hpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
+++ (empty file)
@@ -1,566 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Justin E. Gottchlich 2009.
-// (C) Copyright Vicente J. Botet Escriba 2009.
-// Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
-// copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/stm for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef BOOST_STM_TX_SMART_PTR__HPP
-#define BOOST_STM_TX_SMART_PTR__HPP
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-#include <assert.h>
-#include <boost/stm/transaction.hpp>
-#include <boost/stm/transactional_object.hpp>
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-namespace boost { namespace stm {
-
-template <typename T>
-class rd_ptr;
-template <typename T>
-class wr_ptr;
-template <typename T>
-class upgrd_ptr;
-
-//-----------------------------------------------------------------------------
-// class tx_obj wraps a transactional_object providing builting operators
-//-----------------------------------------------------------------------------
-
-template <typename T>
-class tx_obj {
-public:
- transactional_object<T> obj_;
-
- //-----------------------------------------------------------------------------
- // default constructor valid ony if T has a default constructor
-
- tx_obj() : obj_() {}
-
- //
- template<class Y>
- tx_obj(tx_obj<Y> const& r) : obj_(r.ref()) {}
-
- template <typename T1>
- tx_obj(T1 p1) : obj_(p1) {}
- ~tx_obj() {}
- #if 0
- bool operator==(const tx_obj<T>& rhs) const {
- return this->ref()==rhs.ref();
- }
-
- bool operator==(const T& rhs) const {
- return this->ref()==rhs;
- }
- #endif
-
- //operator T() const { return *this->get(); }
-
- T* operator->() {
- return this->get();
- }
- const T* operator->() const {
- return this->get();
- }
- T& operator*() {
- return this->ref();
- }
- const T& operator*() const {
- return this->ref();
- }
- T* get() {
- return &this->ref();
- }
- const T* get() const {
- return &this->ref();
- }
- T& ref() {
- transaction* tx=transaction::current_transaction();
- if (tx!=0) {
- if (tx->forced_to_abort()) {
- tx->lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
- }
- return tx->write(obj_).value;
- }
- return obj_.value;
- }
-
- const T& ref() const {
- transaction* tx=transaction::current_transaction();
- if (tx!=0) {
- if (tx->forced_to_abort()) {
- tx->lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
- }
- return tx->read(obj_).value;
- }
- return obj_.value;
- }
-
-
- tx_obj& operator--() { --ref(); return *this; }
- T operator--(int) { T n = obj_.value_; --ref(); return n; }
-
- tx_obj& operator++() { ++ref(); return *this; }
- T operator++(int) { T n = obj_.value_; ++ref(); return n; }
-
- tx_obj& operator+=(T const &rhs) {
- ref() += rhs;
- return *this;
- }
-
- T operator+(T const &rhs) const {
- return ref()+rhs;
- }
-
- void swap(tx_obj & other) { // never throws
- std::swap(obj_, other.obj_);
- }
-
-};
-
-// two transactional pointers are equal if they point to the same cache on the current transaction.
-template <typename T, typename U>
-inline bool operator==(const tx_obj<T>& lhs, const tx_obj<U>& rhs) {
- return lhs.ref()==rhs.ref();
-}
-
-template <typename T, typename U>
-inline bool operator==(const T& lhs, const tx_obj<U>& rhs) {
- return lhs==rhs.ref();
-}
-
-template <typename T, typename U>
-inline bool operator==(const tx_obj<T>& lhs, const U& rhs) {
- return lhs.ref()==rhs;
-}
-
-template <typename T, typename U>
-inline bool operator!=(const tx_obj<T>& lhs, const tx_obj<U>& rhs) {
- return lhs.ref()!=rhs.ref();
-}
-
-template<class T> inline void swap(tx_obj<T> & a, tx_obj<T> & b) {
- a.swap(b);
-}
-
-//-----------------------------------------------------------------------------
-// a tx_ptr<T> is an smart pointer to a transactional_object<T> (which contains an instance of T).
-// Reference fields in linked structures should always be tx_ptrs.
-// The result of derreferencing it will be the pointer to the T instance
-// When this pointer is derreference on a transaction the transactional_object<T> is set a written and
-// the transaction specific storage will be used
-// Otherwise the shared storage is used.
-// Used to initialize a rd_ptr<T>, wr_ptr<T>, or upgrd_ptr<T>.
-//-----------------------------------------------------------------------------
-
-template <typename T>
-class tx_ptr {
-public:
- typedef tx_ptr<T> this_type;
- transactional_object<T> * ptr_;
-
- tx_ptr() : ptr_(0) {}
- template<class Y>
- explicit tx_ptr(Y * ptr) : ptr_(new transactional_object<Y>(ptr)) {}
-
- template<class Y>
- explicit tx_ptr(transactional_object<Y>* ptr) : ptr_(ptr) {}
-
- tx_ptr(tx_obj<T>& r) : ptr_(r->obj_) {}
-
- template<class Y>
- tx_ptr(tx_ptr<Y> const& r) : ptr_(r.ptr_) {}// never throws
-
- template<class Y>
- tx_ptr(rd_ptr<Y> const & r) : ptr_(r.ptr_) {}// never throws
-
- template<class Y>
- tx_ptr(wr_ptr<Y> const & r) : ptr_(r.ptr_) {}// never throws
-
- template<class Y>
- tx_ptr(upgrd_ptr<Y> const & r) : ptr_(r.ptr_) {}// never throws
-
- template<class Y>
- tx_ptr & operator=(tx_ptr<Y> const & r) { // never throws
- //this_type(r).swap(*this);
- ptr_=r.ptr_;
- return *this;
- }
- template<class Y>
- tx_ptr& operator=(transactional_object<Y>* ptr) { // never throws
- ptr_=ptr;
- return *this;
- }
-
- //bool operator==(const tx_ptr<T>& rhs) const {
- // return ptr_==rhs.ptr_ || this->get()==rhs.ptr_ || ptr_==rhs.get();
- //}
-
- T* operator->() const {
- return this->get();
- }
- T& operator*() const {
- return *this->get();
- }
- T* get() const {
- if (0==ptr_) return 0;
- transaction* tx=transaction::current_transaction();
- if (tx!=0) {
- if (tx->forced_to_abort()) {
- tx->lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
- }
- return &(tx->write_ptr(ptr_)->value);
- }
- return &ptr_->value;
- }
-
- typedef transactional_object<T>* this_type::*unspecified_bool_type;
-
- operator unspecified_bool_type() const {
- return ptr_ == 0? 0: &this_type::ptr_;
- }
- void swap(tx_ptr & other) { // never throws
- std::swap(ptr_, other.ptr_);
- }
-};
-
-// two transactional pointers are equal if they point to the same cache on the current transaction.
-template <typename T, typename U>
-inline bool operator==(const tx_ptr<T>& lhs, const tx_ptr<U>& rhs) {
- return lhs.ptr_==rhs.ptr_ || lhs.get()==rhs.ptr_ || lhs.ptr_==rhs.get();
-}
-
-template <typename T, typename U>
-inline bool operator!=(const tx_ptr<T>& lhs, const tx_ptr<U>& rhs) {
- return lhs.ptr_!=rhs.ptr_ && lhs.get()!=rhs.ptr_ && lhs.ptr_!=rhs.get();
-}
-
-template<class T>
-inline void swap(tx_ptr<T> & a, tx_ptr<T> & b) {
- a.swap(b);
-}
-
-template <typename T>
-inline tx_ptr<T> make_tx_ptr() {
- return tx_ptr<T>(new transactional_object<T>());
-}
-
-template <typename T, typename A1>
-inline tx_ptr<T> make_tx_ptr(A1 const &a1) {
- return tx_ptr<T>(new transactional_object<T>(a1));
-}
-
-
-template <typename T>
-void delete_ptr(tx_ptr<T> ptr) {
- if (ptr.ptr_==0) return;
- transaction* tx=transaction::current_transaction();
- if (tx==0) delete ptr.ptr_;
- tx->delete_tx_ptr(ptr.ptr_);
-}
-
-
-template <typename T>
-void delete_ptr(transaction& tx, tx_ptr<T> ptr) {
- if (ptr.ptr_==0) return;
- tx.delete_tx_ptr(ptr.ptr_);
-}
-
-template <typename T, typename U>
-inline tx_ptr<T> tx_static_cast(tx_ptr<U> ptr) {
- return tx_ptr<T>(tx_static_cast<T>(ptr->ptr_));
-}
-
-template <typename T, typename U>
-inline tx_ptr<T>* tx_dynamic_cast(tx_ptr<U> ptr) {
- return tx_ptr<T>(tx_dynamic_cast<T>(ptr->ptr_));
-}
-
-
-//-----------------------------------------------------------------------------
-// A rd_ptr<T> ("read pointer") points to an object that the current
-// transaction has opened for read only access.
-// You can only call a const method through a read pointer.
-// A rd_ptr<T> is constructed from an tx_ptr<T> through an explicit constructor.
-// Once a rd_ptr<T> has been constructed, an tx_ptr<T> can be opened for
-// reading simply by assignment (operator=()) into the constructed rd_ptr<T>.
-// It is not safe to derreference a rd_ptr<T> after having assigned the same
-// tx_ptr<T> to a wr_ptr<T>. If this is the case the readen value do not match
-// the writen one. If it is possible to write on the same transaction use
-// upgrd_ptr instead which is safe.
-//-----------------------------------------------------------------------------
-
-template <typename T>
-class rd_ptr {
- typedef rd_ptr<T> this_type;
-public:
- mutable transaction* tx_;
- mutable transactional_object<T>* ptr_;
-
- inline rd_ptr(transaction &t, tx_ptr<T> tx_obj) : tx_(&t),
- ptr_(&t.insert_and_return_read_memory(*tx_obj.ptr_))
- {}
-
- inline rd_ptr(transaction &t, tx_obj<T> const& tx_obj) : tx_(&t),
- ptr_(&t.insert_and_return_read_memory(tx_obj.obj_))
- {}
-
- template<class Y>
- inline rd_ptr & operator=(tx_ptr<Y> r) { // never throws
- //this_type(r).swap(*this);
- ptr_=r.ptr_;
- return *this;
- }
-
- template<class Y>
- inline rd_ptr& operator=(tx_obj<Y> const & r) { // never throws
- //this_type(r).swap(*this);
- ptr_=r.get();
- return *this;
- }
-
- const T* get() const {
- if (tx_->forced_to_abort()) {
- tx_->lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
- }
- return &ptr_->value;
- }
-
- inline const T & operator*() const { return *get(); }
- inline const T* operator->() const { return get(); }
-
-
- typedef transactional_object<T>* this_type::*unspecified_bool_type;
-
- inline operator unspecified_bool_type() const {
- return ptr_ == 0? 0: &this_type::ptr_;
- }
-
-};
-
-template <typename T>
-rd_ptr<T> make_rd_ptr(transaction& tx, tx_ptr<T> ptr) {
- return rd_ptr<T>(tx, ptr);
-}
-template <typename T>
-rd_ptr<T> make_rd_ptr(transaction& tx, tx_obj<T> const & ref) {
- return rd_ptr<T>(tx, ref);
-}
-
-template <typename T>
-rd_ptr<T> make_rd_ptr(tx_ptr<T> ptr) {
- transaction* tx = transaction::current_transaction();
- assert(tx==0);
- return rd_ptr<T>(*tx, ptr);
-}
-
-template <typename T>
-rd_ptr<T> make_rd_ptr(tx_obj<T> const & ref) {
- transaction* tx = transaction::current_transaction();
- assert(tx==0);
- return rd_ptr<T>(*tx, ref);
-}
-
-template <typename T>
-void delete_ptr(rd_ptr<T> ptr) {
- if (ptr.ptr_==0) return;
- ptr.tx_->delete_tx_ptr(ptr.ptr_);
-}
-
-template <typename T>
-void delete_ptr(transaction& tx, rd_ptr<T> ptr) {
- if (ptr.ptr_==0) return;
- tx.delete_tx_ptr(ptr.ptr_);
-}
-
-//-----------------------------------------------------------------------------
-// A upgrd_ptr<T> ("upgradable pointer") points to an object that the current
-// transaction has opened for read only access.
-// You can only call a const method through a read pointer.
-// A upgrd_ptr<T> is constructed from an tx_ptr<T> through a constructor
-// having also the transaction as parameter.
-// Once a rd_ptr<T> has been constructed, an tx_ptr<T> can be opened for
-// reading simply by assignment (operator=()) into the constructed rd_ptr<T>.
-// It is safe to derreference a rd_ptr<T> after having assigned the same
-// tx_ptr<T> to a wr_ptr<T>.
-// A upgrd_ptr<T> can be upgraded to a wr_ptr<T> through a constructor.
-//-----------------------------------------------------------------------------
-
-template <typename T>
-class upgrd_ptr {
- typedef upgrd_ptr<T> this_type;
-public:
- mutable transaction* tx_;
- mutable transactional_object<T>* ptr_;
- mutable bool written_;
-
- inline upgrd_ptr(transaction &t, tx_ptr<T> tx_obj) : tx_(&t),
- ptr_(const_cast<transactional_object<T>*>(t.read_ptr(tx_obj.ptr_))), written_(false) {}
-
- template<class Y>
- upgrd_ptr & operator=(tx_ptr<Y> const& r) { // never throws
- //this_type(r).swap(*this);
- transaction* tx=transaction::current_transaction();
- if (tx==0) throw "error";
- tx_=tx;
- ptr_=r.ptr_;
- written_=false;
- return *this;
- }
-
- const T* get() const {
- if (tx_->forced_to_abort()) {
- tx_->lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
- }
-
- // we don't hold the written object and
- // we have alrerady written an object on this transaction maybe is this one
- if (!written_ && tx_->written()) {
- transactional_object<T>* temp = tx_->get_written(*ptr_);
-
- // if we found something, store this as the tx_ptr_
- if (0 != temp) {
- ptr_ = temp;
- written_ = true;
- }
- }
-
- return &ptr_->value;
- }
-
- inline T const & operator*() const { return *get(); }
- inline T const * operator->() const { return get(); }
-
- //operator const T*() const { return get(); }
-
- typedef transactional_object<T>* this_type::*unspecified_bool_type;
-
- inline operator unspecified_bool_type() const {
- return ptr_ == 0? 0: &this_type::ptr_;
- }
-
- inline void write_ptr(transactional_object<T>* ptr) {
- ptr_ = ptr;
- written_ = true;
- }
-
- T* write_ptr() {
- if (tx_->forced_to_abort()) {
- tx_->lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
- }
-
- // we are already holding the written object
- if (written_) return ptr_;
-
- transactional_object<T>* temp = tx_->get_written(ptr_);
-
- // if we found something, store this as the tx_ptr_
- if (0 != temp) {
- ptr_ = temp;
- written_ = true;
- } else {
- ptr_ = tx_->write_ptr(ptr_);
- written_ = true;
- }
-
- return ptr_;
- }
-
-};
-
-template <typename T>
-void delete_ptr(upgrd_ptr<T> const& ptr) {
- if (ptr.ptr_==0) return;
- if (ptr.tx_==0) delete ptr.ptr_;
- ptr.tx_->delete_tx_ptr(ptr.ptr_);
-}
-
-template <typename T>
-void delete_ptr(transaction& tx, upgrd_ptr<T> const& ptr) {
- if (ptr.ptr_==0) return;
- tx.delete_tx_ptr(ptr.ptr_);
-}
-
-//-----------------------------------------------------------------------------
-// A wr_ptr<T> ("write pointer") points to a shared object that the current transaction has opened for writing.
-// A wr_ptr<T> is initialized explicitly from an tx_ptr<T>.
-// A wr_ptr<T> can also be explicitly constructed from a upgrd_ptr<T> as an upgrade-to-writable operation.
-//-----------------------------------------------------------------------------
-
-template <typename T>
-class wr_ptr {
- typedef wr_ptr<T> this_type;
-public:
- mutable transaction& tx_;
- mutable transactional_object<T>* ptr_;
-
- inline wr_ptr(transaction &t, tx_ptr<T> tx_obj) : tx_(t),
- ptr_(t.write_ptr(tx_obj.ptr_))
- {}
-
- inline wr_ptr(transaction &t, upgrd_ptr<T> tx_obj) : tx_(t),
- ptr_(t.write_ptr(tx_obj.ptr_))
- {
- tx_obj.write_ptr(ptr_);
- }
-
- T* get() {
- if (tx_.forced_to_abort()) {
- tx_.lock_and_abort();
- throw aborted_transaction_exception("aborting transaction");
- }
- return &ptr_->value;
- }
-
- inline T& operator*() { return *get(); }
- inline T* operator->() { return get(); }
-
- typedef transactional_object<T>* this_type::*unspecified_bool_type;
-
- inline operator unspecified_bool_type() const {
- return ptr_ == 0? 0: &this_type::ptr_;
- }
-};
-
-template <typename T>
-inline wr_ptr<T> make_wr_ptr(transaction& tx, tx_ptr<T>& ptr) {
- return wr_ptr<T>(tx, ptr);
-}
-
-
-template <typename T>
-inline wr_ptr<T> make_wr_ptr(tx_ptr<T>& ptr) {
- transaction* tx = transaction::current_transaction();
- return wr_ptr<T>(*tx, ptr);
-}
-
-template <typename T>
-inline void delete_ptr(wr_ptr<T> ptr) {
- if (ptr.ptr_==0) return;
- ptr.tx_.delete_tx_ptr(ptr.ptr_);
-}
-
-template <typename T>
-inline void delete_ptr(transaction& tx, wr_ptr<T> const& ptr) {
- if (ptr.ptr_==0) return;
- tx.delete_tx_ptr(ptr.ptr_);
-}
-
-}}
-#endif
-
-

Modified: sandbox/stm/branches/vbe/libs/stm/example/list.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/example/list.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/example/list.cpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
@@ -39,6 +39,12 @@
    tx_ptr<list_node<T> > next_;
 };
 
+template <typename OSTREAM, typename T>
+OSTREAM& operator<<(OSTREAM& os, list_node<T>& v) {
+ os << v.value_;
+ return os;
+}
+
 //--------------------------------------------------------------------------
 template <typename T>
 class list
@@ -51,14 +57,18 @@
     list()
     : head_(BOOST_STM_NEW_1(transactional_object<list_node<T> >()))
     , size_(BOOST_STM_NEW_1(transactional_object<std::size_t>(0)))
- { }
+ {
+ std::cout << "list().head_" << *head_.get() << std::endl;
+ std::cout << "list().size_" << *size_.get() << std::endl;
+ }
 
     ~list() { }
 
     std::size_t size() const {
         std::size_t res=0;
         use_atomic(_) {
- rd_ptr<std::size_t> s(_, size_);
+ upgrd_ptr<std::size_t> s(_, size_);
+ std::cout << "size_.get()" << s.get() << std::endl;
             res=*s;
         }
         return res;
@@ -68,24 +78,33 @@
     // find the location to insert the node. if the value already exists, fail
     //--------------------------------------------------------------------------
     void insert(const T& val) {
- use_atomic(_) {
- cerr << "try" << endl;
+ cerr << __LINE__ << " insert" << endl;
+ // use_atomic(_) {
+ for (boost::stm::transaction _; !_.committed() && _.restart(); _.end()) {
+ cerr << __LINE__ << " insert" << endl;
             upgrd_ptr<list_node<T> > prev(_, head_);
             upgrd_ptr<list_node<T> > curr(_, head_->next_);
- while (curr) {
- cerr << "curr" << curr << endl;
+ while (curr.get()!=0) {
+ cerr << __LINE__ << " curr" << curr.get() << endl;
                 if (curr->value_ == val) return;
                 else if (curr->value_ > val) break;
                 prev = curr;
                 curr = curr->next_;
             }
- if (!curr || (curr->value_ > val)) {
+ cerr << __LINE__ << " insert" << endl;
+ if (curr.get()==0 || (curr->value_ > val)) {
+ cerr << __LINE__ << " inserting" << endl;
                 wr_ptr<list_node<T> > insert_point(_,prev);
+ cerr << __LINE__ << " inserting" << endl;
                 insert_point->next_=BOOST_STM_NEW(_,transactional_object<list_node<T> >(val, curr));
- ++(*size_);
+ cerr << __LINE__ << " inserting" << endl;
+ //wr_ptr<std::size_t > size_tx(_,size_);
+ //cerr << __LINE__ << " inserting" << endl;
+ //++(*size_tx);
 
             }
         }
+ cerr << __LINE__ << " insert" << endl;
    }
 
     // search function
@@ -118,7 +137,8 @@
                     mod_point->next_=curr->next_;
                     // delete curr...
                     delete_ptr(_,curr);
- --(*size_);
+ wr_ptr<std::size_t > size_tx(_,size_);
+ //--(*size_tx);
                     break;
                 } else if (curr->value_ > val) {
                     // this means the search failed
@@ -142,7 +162,9 @@
         cerr << __LINE__ << " create" << endl;
         l=BOOST_STM_NEW(_,transactional_object<test::list<int> >());
         cerr << __LINE__ << " create" << endl;
- cerr << l->size() << endl;
+ cerr << " create size " << l->size() << endl;
+ //cerr << " insert " << l.get() << endl;
+ //l->insert(1);
     } catch (...) {
         cerr << "aborted" << endl;
     }
@@ -152,7 +174,9 @@
     //thread_initializer thi;
     atomic(_) {
         cerr << __LINE__ << " try" << endl;
+ cerr << __LINE__ << " insert1 size " << l->size() << endl;
         make_wr_ptr(_,l)->insert(1);
+ cerr << __LINE__ << " insert1 size " << l->size() << endl;
     } catch(...) {
         cerr << __LINE__ << " aborted" << endl;
     }
@@ -171,7 +195,7 @@
     }
 }
 bool check_size(std::size_t val) {
- int res;
+ int res=true;
     use_atomic(_) {
         //cerr << "size" <<make_rd_ptr(_,l)->size()<< endl;
         res = make_rd_ptr(_,l)->size()==val;
@@ -181,8 +205,8 @@
 int test1() {
     create();
     insert1();
- bool fails=true;
- fails= !check_size(1);
+ bool fails=false;
+ //fails= fails || !check_size(0);
     #if 0
     thread th1(insert1);
     //thread th2(insert2);
@@ -198,7 +222,7 @@
     //boost::stm::delete_ptr(l);
     return 0;
     #else
- return true;
+ return 0;
     #endif
 }
 
@@ -207,7 +231,6 @@
     transaction::do_deferred_updating();
     transaction::initialize();
     thread_initializer thi;
- //srand(time(0));
 
     int res=0;
     res+=test1();

Modified: sandbox/stm/branches/vbe/libs/stm/example/non_tx_counter.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/example/non_tx_counter.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/example/non_tx_counter.cpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
@@ -96,7 +96,8 @@
     th3.join();
     th4.join();
 
- bool fails=!check(2);
+ bool fails=false;
+ fails = fails || !check(2);
     fails = fails || !assign();
     fails = fails || !test_const(counter);
     return fails;
@@ -107,10 +108,7 @@
     transaction::do_deferred_updating();
     transaction::initialize();
     thread_initializer thi;
- srand(time(0));
 
- test_counter();
-
- return 0;
+ return test_counter();
 
 }

Modified: sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp 2009-10-11 18:14:01 EDT (Sun, 11 Oct 2009)
@@ -33,7 +33,9 @@
 transaction::MutexThreadMap transaction::latmLockedLocksOfThreadMap_;
 transaction::MutexSet transaction::tmConflictingLocks_;
 transaction::DeletionBuffer transaction::deletionBuffer_;
+#ifndef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
 transaction::ThreadTransactionsStack transaction::threadTransactionsStack_;
+#endif
 
 size_t transaction::global_clock_ = 0;
 size_t transaction::stalls_ = 0;


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