Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56114 - in sandbox/stm/branches/vbe/boost/stm: . detail
From: vicente.botet_at_[hidden]
Date: 2009-09-08 16:56:17


Author: viboes
Date: 2009-09-08 16:56:15 EDT (Tue, 08 Sep 2009)
New Revision: 56114
URL: http://svn.boost.org/trac/boost/changeset/56114

Log:
TBoost.Stm vbe

Text files modified:
   sandbox/stm/branches/vbe/boost/stm/base_transaction.hpp | 16 -
   sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp | 34 ++--
   sandbox/stm/branches/vbe/boost/stm/detail/tx_ptr.hpp | 274 ++++++++++++++++++++++-----------------
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 41 +++--
   4 files changed, 191 insertions(+), 174 deletions(-)

Modified: sandbox/stm/branches/vbe/boost/stm/base_transaction.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/base_transaction.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/base_transaction.hpp 2009-09-08 16:56:15 EDT (Tue, 08 Sep 2009)
@@ -52,7 +52,7 @@
 namespace boost { namespace stm {
 
 //-----------------------------------------------------------------------------
-// forward declarations
+// forward declarations
 //-----------------------------------------------------------------------------
 
 template <class T> void cache_deallocate(T*);
@@ -179,10 +179,9 @@
 
 //-----------------------------------------------------------------------------
 // this is the base class of all the transactional objects.
-// it tracks:
+// it tracks:
 // transactionThread_: the thread identifier holding the write acces to this transactional object
-// transaction_: the pointer to the transaction
-// version: the version when performing validation
+// version: the version when performing validation
 // newMemory_: states whether this object is a new object
 // transactional objets must specialize the pure virtual functions
 // copy_state(base_transaction_object const * const rhs)
@@ -200,7 +199,6 @@
 
    base_transaction_object() : transactionThread_(kInvalidThread),
       newMemory_(0)
- , transaction_(0)
 #if PERFORMING_VALIDATION
       ,version_(0)
 #endif
@@ -210,7 +208,6 @@
     base_transaction_object(const base_transaction_object &t)
         : transactionThread_(kInvalidThread)
         , newMemory_(0)
- , transaction_(t)
 #if PERFORMING_VALIDATION
         , version_(0)
 #endif
@@ -240,9 +237,6 @@
    void new_memory(size_t rhs) const { newMemory_ = rhs; }
    size_t const & new_memory() const { return newMemory_; }
 
- transaction*& get_transaction() const {return transaction_;}
- //transaction* get_transaction() const {return transaction_;}
-
 #if PERFORMING_VALIDATION
    size_t version_;
 #endif
@@ -296,9 +290,6 @@
    mutable size_t transactionThread_;
 
    mutable size_t newMemory_;
-public:
- mutable transaction* transaction_;
-private:
 #if USE_STM_MEMORY_MANAGER
    static Mutex transactionObjectMutex_;
    static MemoryPool<base_transaction_object> memory_;
@@ -457,7 +448,6 @@
 
     transactional_object & operator=(transactional_object const & r) // =default never throws
     {
- this->transaction_=r.transaction_;
         value = r.value;
         return *this;
     }

Modified: sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp 2009-09-08 16:56:15 EDT (Tue, 08 Sep 2009)
@@ -398,7 +398,7 @@
       if (i->first == threadId) continue;
       unlock(i->second);
    }
-#endif
+#endif
 }
 
 //--------------------------------------------------------------------------
@@ -442,7 +442,7 @@
       unlock(i->second);
    }
 #endif
- hasMutex_ = 0;
+ hasMutex_ = 0;
 }
 
 //--------------------------------------------------------------------------
@@ -459,7 +459,7 @@
 inline transaction::transaction() :
    threadId_(THREAD_ID),
 #if USE_SINGLE_THREAD_CONTEXT_MAP
-////////////////////////////////////////
+////////////////////////////////////////
    context_(*tss_context_map_.find(threadId_)->second),
 
 #ifdef BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
@@ -475,7 +475,7 @@
 #else
    forcedToAbortRef_(false),
 #endif
-#else
+#else
    write_list_ref_(&context_.tx_.writeMem),
    bloomRef_(&context_.tx_.bloom),
    wbloomRef_(&context_.tx_.wbloom),
@@ -487,8 +487,8 @@
 #else
    forcedToAbortRef_(false),
 #endif
-#endif
-#endif
+#endif
+#endif
 #ifndef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
    mutexRef_(threadMutexes_.find(threadId_)->second),
 
@@ -505,11 +505,11 @@
 #endif
 #endif
    transactionsRef_(transactions(threadId_)),
-
-
-////////////////////////////////////////
+
+
+////////////////////////////////////////
 #else
-////////////////////////////////////////
+////////////////////////////////////////
 #ifndef DISABLE_READ_SETS
    readListRef_(*threadReadLists_.find(threadId_)->second),
 #endif
@@ -544,7 +544,7 @@
 
    transactionsRef_(transactions(threadId_)),
 
-////////////////////////////////////////
+////////////////////////////////////////
 #endif
 
    hasMutex_(0), priority_(0),
@@ -1666,7 +1666,7 @@
 
       tx_type_ref() = eNormalTx;
 #if PERFORMING_LATM
- get_tx_conflicting_locks().clear();
+ get_tx_conflicting_locks().clear();
       /* BACKTRACE
 #2 0x00459309 in std::set<__pthread_mutex_t**, std::less<__pthread_mutex_t**>,
 std::allocator<__pthread_mutex_t**> >::clear (this=0x0)
@@ -1853,9 +1853,7 @@
       if (using_move_semantics()) i->first->move_state(i->second);
       else i->first->copy_state(i->second);
       i->first->transaction_thread(kInvalidThread);
- i->first->get_transaction()=0;
 
- //delete i->second;
       cache_release(i->second);
    }
 
@@ -1869,7 +1867,6 @@
    j != deletedMemoryList().end(); ++j)
    {
       (*j)->transaction_thread(kInvalidThread);
- (*j)->get_transaction()=0;
    }
 
    deletedMemoryList().clear();
@@ -1979,7 +1976,6 @@
    for (MemoryContainerList::iterator i = newMemoryList().begin(); i != newMemoryList().end(); ++i)
    {
       (*i)->transaction_thread(kInvalidThread);
- (*i)->get_transaction()=0;
       (*i)->new_memory(0);
    }
 
@@ -2001,7 +1997,6 @@
       // on it.
       //-----------------------------------------------------------------------
       i->first->transaction_thread(kInvalidThread);
- i->first->get_transaction()=0;
       i->first->new_memory(0);
 
       //-----------------------------------------------------------------------
@@ -2037,7 +2032,6 @@
       else i->first->copy_state(i->second);
 
       i->first->transaction_thread(kInvalidThread);
- i->first->get_transaction()=0;
       i->first->new_memory(0);
 
 #if PERFORMING_VALIDATION
@@ -2120,7 +2114,7 @@
    if (writes() > 3) allow_stall = false;
 
    //--------------------------------------------------------------------------
- // FOR THE TIME BEING, DO NOT ALLOW STALLS AT ALL! Stalls somehow cause
+ // FOR THE TIME BEING, DO NOT ALLOW STALLS AT ALL! Stalls somehow cause
    // Sebastian's account code to break ... we need to investigate why and fix it.
    //
    // Until such time, stalling txes for increased concurrency MUST be disabled.
@@ -2129,7 +2123,7 @@
    allow_stall = false;
 
    //--------------------------------------------------------------------------
- // FOR THE TIME BEING, DO NOT ALLOW STALLS AT ALL! Stalls somehow cause
+ // FOR THE TIME BEING, DO NOT ALLOW STALLS AT ALL! Stalls somehow cause
    // Sebastian's account code to break ... we need to investigate why and fix it.
    //
    // Until such time, stalling txes for increased concurrency MUST be disabled.

Modified: sandbox/stm/branches/vbe/boost/stm/detail/tx_ptr.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/tx_ptr.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/tx_ptr.hpp 2009-09-08 16:56:15 EDT (Tue, 08 Sep 2009)
@@ -1,10 +1,10 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Justin E. Gottchlich 2009.
-// (C) Copyright Vicente J. Botet Escriba 2009.
+// (C) Copyright Justin E. Gottchlich 2009.
+// (C) Copyright Vicente J. Botet Escriba 2009.
 // Distributed under the Boost
-// Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
 // copy at http://www.boost.org/LICENSE_1_0.txt)
 //
 // See http://www.boost.org/libs/synchro for documentation.
@@ -29,7 +29,7 @@
 class wr_ptr;
 template <typename T>
 class upgrd_ptr;
-
+
 //-----------------------------------------------------------------------------
 // class tx_obj wraps a transactional_object providing builting operators
 //-----------------------------------------------------------------------------
@@ -43,24 +43,26 @@
     // default constructor valid ony if T has a default constructor
 
     tx_obj() : obj_() {}
-
- //
- template<class Y>
+
+ //
+ template<class Y>
     tx_obj(tx_obj<Y> const& r) : obj_(r.ref()) {} // throws only if obj_ contructor throws
-
+
     template <typename T1>
     tx_obj(T1 p1) : obj_(p1) {}
-
+
+ #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();
     }
@@ -74,10 +76,10 @@
         return this->ref();
     }
     T* get() {
- return &this->ref();
+ return &this->ref();
     }
     const T* get() const {
- return &this->ref();
+ return &this->ref();
     }
     T& ref() {
         transaction* tx=transaction::current_transaction();
@@ -102,11 +104,11 @@
         }
         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; }
 
@@ -118,20 +120,48 @@
     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>
+bool operator==(const tx_obj<T>& lhs, const tx_obj<U>& rhs) {
+ return lhs.ref()==rhs.ref();
+}
+
+template <typename T, typename U>
+bool operator==(const T& lhs, const tx_obj<U>& rhs) {
+ return lhs==rhs.ref();
+}
+
+template <typename T, typename U>
+bool operator==(const tx_obj<T>& lhs, const U& rhs) {
+ return lhs.ref()==rhs;
+}
+
+template <typename T, typename U>
+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).
+// 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
+// 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>.
+// Used to initialize a rd_ptr<T>, wr_ptr<T>, or upgrd_ptr<T>.
 //-----------------------------------------------------------------------------
-
+
 template <typename T>
 class tx_ptr {
 public:
@@ -139,41 +169,41 @@
     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(Y * ptr) : ptr_(new transactional_object<Y>(ptr)) {}
+
     explicit tx_ptr(transactional_object<T>* ptr) : ptr_(ptr) {}
-
+
     tx_ptr(tx_obj<T>& r) : ptr_(r->obj_) {}
 
- template<class Y>
+ template<class Y>
     tx_ptr(tx_ptr<Y> const& r) : ptr_(r.ptr_) {}// never throws
-
- template<class Y>
+
+ template<class Y>
     tx_ptr(rd_ptr<Y> const & r) : ptr_(r.ptr_) {}// never throws
 
- template<class Y>
+ template<class Y>
     tx_ptr(wr_ptr<Y> const & r) : ptr_(r.ptr_) {}// never throws
 
- template<class Y>
+ 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
+ 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
+ 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();
     }
@@ -192,7 +222,7 @@
         }
         return &ptr_->value;
     }
-
+
     typedef transactional_object<T>* this_type::*unspecified_bool_type;
 
     operator unspecified_bool_type() const {
@@ -201,9 +231,9 @@
     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.
+// two transactional pointers are equal if they point to the same cache on the current transaction.
 template <typename T, typename U>
 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();
@@ -218,27 +248,27 @@
     a.swap(b);
 }
 
-template <typename T>
+template <typename T>
 tx_ptr<T> make_tx_ptr() {
     return tx_ptr<T>(new transactional_object<T>());
 }
 
-template <typename T, typename A1>
+template <typename T, typename A1>
 tx_ptr<T> make_tx_ptr(A1 const &a1) {
     return tx_ptr<T>(new transactional_object<T>(a1));
 }
 
 
-template <typename T>
+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_;
+ if (tx==0) delete ptr.ptr_;
     tx->delete_tx_ptr(ptr.ptr_);
 }
 
 
-template <typename T>
+template <typename T>
 void delete_ptr(transaction& tx, tx_ptr<T> ptr) {
     if (ptr.ptr_==0) return;
     tx.delete_tx_ptr(ptr.ptr_);
@@ -248,7 +278,7 @@
 static 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>
 static tx_ptr<T>* tx_dynamic_cast(tx_ptr<U> ptr) {
     return tx_ptr<T>(tx_dynamic_cast<T>(ptr->ptr_));
@@ -256,111 +286,111 @@
 
 
 //-----------------------------------------------------------------------------
-// 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
+// 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 transactional_object<T>* ptr_;
-
- inline rd_ptr(transaction &t, tx_ptr<T> tx_obj) :
+
+ inline rd_ptr(transaction &t, tx_ptr<T> tx_obj) :
         ptr_(&t.insert_and_return_read_memory(*tx_obj.ptr_))
     {}
 
- inline rd_ptr(transaction &t, tx_obj<T> const& tx_obj) :
+ inline rd_ptr(transaction &t, tx_obj<T> const& tx_obj) :
         ptr_(&t.insert_and_return_read_memory(tx_obj.obj_))
     {}
 
- template<class Y>
- rd_ptr & operator=(tx_ptr<Y> r) { // never throws
+ template<class Y>
+ rd_ptr & operator=(tx_ptr<Y> r) { // never throws
         //this_type(r).swap(*this);
         ptr_=r.ptr_;
         return *this;
     }
-
- template<class Y>
- rd_ptr& operator=(tx_obj<Y> const & r) { // never throws
+
+ template<class Y>
+ rd_ptr& operator=(tx_obj<Y> const & r) { // never throws
         //this_type(r).swap(*this);
         ptr_=r.get();
         return *this;
     }
-
+
     const T* get() const {
         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;
 
- operator unspecified_bool_type() const
+ operator unspecified_bool_type() const
     {
         return ptr_ == 0? 0: &this_type::ptr_;
     }
 
 };
 
-template <typename T>
+template <typename T>
 rd_ptr<T> make_rd_ptr(transaction& tx, tx_ptr<T> ptr) {
     return rd_ptr<T>(tx, ptr);
 }
-template <typename T>
+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>
+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>
+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>
+template <typename T>
 void delete_ptr(rd_ptr<T> ptr) {
     if (ptr.ptr_==0) return;
     transaction* tx=transaction::current_transaction();
- if (tx==0) delete ptr.ptr_;
+ if (tx==0) delete ptr.ptr_;
     tx->delete_tx_ptr(ptr.ptr_);
 }
 
-template <typename T>
+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.
+// 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>
@@ -370,13 +400,13 @@
     mutable transaction* tx_;
     mutable transactional_object<T>* ptr_;
     mutable bool written_;
-
+
     //inline upgrd_ptr() : tx_(0) {}
     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
+ 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";
@@ -392,11 +422,11 @@
             throw aborted_transaction_exception("aborting transaction");
         }
 
- // we don't hold the written object and
+ // 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;
@@ -411,10 +441,10 @@
     inline T const * operator->() const { return get(); }
 
     //operator const T*() const { return get(); }
-
+
     typedef transactional_object<T>* this_type::*unspecified_bool_type;
 
- operator unspecified_bool_type() const
+ operator unspecified_bool_type() const
     {
         return ptr_ == 0? 0: &this_type::ptr_;
     }
@@ -433,7 +463,7 @@
         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;
@@ -448,23 +478,23 @@
 
 };
 
-template <typename T>
+template <typename T>
 void delete_ptr(upgrd_ptr<T> const& ptr) {
     if (ptr.ptr_==0) return;
- if (ptr.tx_==0) delete ptr.ptr_;
+ if (ptr.tx_==0) delete ptr.ptr_;
     ptr.tx_->delete_tx_ptr(ptr.ptr_);
 }
 
-template <typename T>
+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 sh_ptr<T>.
-// A wr_ptr<T> can also be explicitly constructed from a upgrd_ptr<T> as an upgrade-to-writable operation.
+// 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>
@@ -473,7 +503,7 @@
 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_))
     {}
@@ -491,37 +521,37 @@
         }
         return &ptr_->value;
     }
-
+
     inline T& operator*() { return *get(); }
     inline T* operator->() { return get(); }
-
+
     typedef transactional_object<T>* this_type::*unspecified_bool_type;
 
- operator unspecified_bool_type() const
+ operator unspecified_bool_type() const
     {
         return ptr_ == 0? 0: &this_type::ptr_;
     }
 };
 
-template <typename T>
+template <typename T>
 wr_ptr<T> make_wr_ptr(transaction& tx, tx_ptr<T>& ptr) {
     return wr_ptr<T>(tx, ptr);
 }
 
 
-template <typename T>
+template <typename T>
 wr_ptr<T> make_wr_ptr(tx_ptr<T>& ptr) {
     transaction* tx = transaction::current_transaction();
     return wr_ptr<T>(*tx, ptr);
 }
 
-template <typename T>
+template <typename T>
 void delete_ptr(wr_ptr<T> ptr) {
     if (ptr.ptr_==0) return;
     ptr.tx_.delete_tx_ptr(ptr.ptr_);
 }
 
-template <typename T>
+template <typename T>
 void delete_ptr(transaction& tx, wr_ptr<T> const& ptr) {
     if (ptr.ptr_==0) return;
     tx.delete_tx_ptr(ptr.ptr_);
@@ -533,14 +563,14 @@
 class read_ptr
 {
 public:
-
- inline read_ptr(transaction &t, T const &tx_obj) :
+
+ inline read_ptr(transaction &t, T const &tx_obj) :
       t_(t), tx_ptr_(&const_cast<T&>(t_.read(tx_obj))), written_(false)
    {}
 
    const T* get() const
    {
- if (t_.forced_to_abort())
+ if (t_.forced_to_abort())
       {
          t_.lock_and_abort();
          throw aborted_transaction_exception("aborting transaction");
@@ -550,7 +580,7 @@
       if (written_) return tx_ptr_;
 
       T* temp = t_.get_written(*tx_ptr_);
-
+
       // if we found something, store this as the tx_ptr_
       if (0 != temp)
       {
@@ -568,7 +598,7 @@
 
    T* write_ptr()
    {
- if (t_.forced_to_abort())
+ if (t_.forced_to_abort())
       {
          t_.lock_and_abort();
          throw aborted_transaction_exception("aborting transaction");
@@ -578,7 +608,7 @@
       if (written_) return tx_ptr_;
 
       T* temp = t_.get_written(*tx_ptr_);
-
+
       // if we found something, store this as the tx_ptr_
       if (0 != temp)
       {
@@ -595,7 +625,7 @@
    }
 
 private:
-
+
    mutable transaction &t_;
    mutable T *tx_ptr_;
    mutable bool written_;
@@ -607,14 +637,14 @@
 class write_ptr
 {
 public:
-
- inline write_ptr(transaction &t, T & tx_obj) :
+
+ inline write_ptr(transaction &t, T & tx_obj) :
       t_(t), tx_obj_(t_.write(tx_obj))
    {}
 
    inline T& operator*()
    {
- if (t_.forced_to_abort())
+ if (t_.forced_to_abort())
       {
          t_.lock_and_abort();
          throw aborted_transaction_exception("aborting transaction");
@@ -624,7 +654,7 @@
 
    inline T* operator->()
    {
- if (t_.forced_to_abort())
+ if (t_.forced_to_abort())
       {
          t_.lock_and_abort();
          throw aborted_transaction_exception("aborting transaction");
@@ -632,7 +662,7 @@
       return &tx_obj_;
    }
 
-private:
+private:
    mutable transaction &t_;
    mutable T &tx_obj_;
 };

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-09-08 16:56:15 EDT (Tue, 08 Sep 2009)
@@ -120,18 +120,18 @@
 #endif
 
 class transaction;
- struct TransactionsStack {
- typedef std::stack<transaction*> cont_type;
- cont_type stack_;
- TransactionsStack() {
- // the stack at least one element (0) so we can always call to top, i.e. current transaction is 0
- stack_.push(0);
- }
- void push(transaction* ptr) {stack_.push(ptr);}
- void pop() {stack_.pop();}
- std::size_t size() {return stack_.size();}
- transaction* top() {return stack_.top();}
- };
+struct TransactionsStack {
+ typedef std::stack<transaction*> cont_type;
+ cont_type stack_;
+ TransactionsStack() {
+ // the stack at least one element (0) so we can always call to top, i.e. current transaction is 0
+ stack_.push(0);
+ }
+ void push(transaction* ptr) {stack_.push(ptr);}
+ void pop() {stack_.pop();}
+ std::size_t size() {return stack_.size();}
+ transaction* top() {return stack_.top();}
+};
 
 ///////////////////////////////////////////////////////////////////////////////
 // transaction Class
@@ -218,9 +218,9 @@
         WriteContainer writeMem;
         bloom_filter wbloom;
         bloom_filter bloom;
- TxType txType;
+ TxType txType; // 2 bits
 
- int abort;
+ int abort; // bool 1 bit
     };
 
 
@@ -2005,9 +2005,9 @@
 
 
    // transaction specific data
- int hasMutex_;
+ int hasMutex_; // bool - 1 bit
    mutable size_t priority_;
- transaction_state state_;
+ transaction_state state_; // 2bits
    size_t reads_;
    mutable size_t startTime_;
 
@@ -2258,13 +2258,16 @@
 // rand()+1 check is necessarily complex so smart compilers can't
 // optimize the if away
 //---------------------------------------------------------------------------
-//#define use_atomic(T) if (0 != rand()+1) for (boost::stm::transaction T; !T.committed() && T.restart(); T.end())
-//#define try_atomic(T) if (0 != rand()+1) for (boost::stm::transaction T; !T.committed() && T.restart(); T.no_throw_end()) try
-//#define atomic(T) if (0 != rand()+1) for (boost::stm::transaction T; !T.committed() && T.check_throw_before_restart() && T.restart_if_not_inflight(); T.no_throw_end()) try
 
+#ifdef BOOST_STM_COMPILER_DONT_DESTROY_FOR_VARIABLES
+#define use_atomic(T) if (0==rnd()+1) {} else for (boost::stm::transaction T; !T.committed() && T.restart(); T.end())
+#define try_atomic(T) if (0==rnd()+1) {} else for (boost::stm::transaction T; !T.committed() && T.restart(); T.no_throw_end()) try
+#define atomic(T) if (0==rnd()+1) {} else for (boost::stm::transaction T; !T.committed() && T.check_throw_before_restart() && T.restart_if_not_inflight(); T.no_throw_end()) try
+#else
 #define use_atomic(T) for (boost::stm::transaction T; !T.committed() && T.restart(); T.end())
 #define try_atomic(T) for (boost::stm::transaction T; !T.committed() && T.restart(); T.no_throw_end()) try
 #define atomic(T) for (boost::stm::transaction T; !T.committed() && T.check_throw_before_restart() && T.restart_if_not_inflight(); T.no_throw_end()) try
+#endif
 
 
 #define catch_before_retry(E) catch (boost::stm::aborted_tx &E)


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