Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58880 - in sandbox/stm/branches/vbe/boost/stm: . detail non_tx/detail tx txw
From: vicente.botet_at_[hidden]
Date: 2010-01-10 15:40:02


Author: viboes
Date: 2010-01-10 15:40:00 EST (Sun, 10 Jan 2010)
New Revision: 58880
URL: http://svn.boost.org/trac/boost/changeset/58880

Log:
TBoost.STM vbe: polymorphic write used on smart pointers

Text files modified:
   sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 12 +++---
   sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp | 2
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 72 +++++++++++++++++++++------------------
   sandbox/stm/branches/vbe/boost/stm/tx/mixin.hpp | 14 +++---
   sandbox/stm/branches/vbe/boost/stm/tx/object.hpp | 10 ++--
   sandbox/stm/branches/vbe/boost/stm/tx/pointer.hpp | 22 ++++++------
   sandbox/stm/branches/vbe/boost/stm/tx/shallow_transaction_object.hpp | 2
   sandbox/stm/branches/vbe/boost/stm/tx/trivial_transaction_object.hpp | 4 +-
   sandbox/stm/branches/vbe/boost/stm/tx_ptr.hpp | 60 ++++++++++++++++----------------
   sandbox/stm/branches/vbe/boost/stm/txw/transactional_object.hpp | 2
   10 files changed, 103 insertions(+), 97 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-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -86,7 +86,7 @@
 
 #if (defined(BOOST_STM_USE_DEFAULT_MEMORY_MANAGER) && defined(BOOST_STM_USE_GLOBAL_MEMORY_MANAGER)) || \
     (defined(BOOST_STM_USE_GLOBAL_MEMORY_MANAGER) && defined(BOOST_STM_USE_CLASS_MEMORY_MANAGER)) || \
- (defined(BOOST_STM_USE_CLASS_MEMORY_MANAGER) && defined(BOOST_STM_USE_DEFAULT_MEMORY_MANAGER))
+ (defined(BOOST_STM_USE_CLASS_MEMORY_MANAGER) && defined(BOOST_STM_USE_DEFAULT_MEMORY_MANAGER))
 #error only one of BOOST_STM_USE_DEFAULT_MEMORY_MANAGER, BOOST_STM_USE_GLOBAL_MEMORY_MANAGER or BOOST_STM_USE_CLASS_MEMORY_MANAGER can be defined
 #endif
 
@@ -123,7 +123,7 @@
 // define USE_BLOOM_FILTER if you want STM uses Bloom filters for read set
 #define USE_BLOOM_FILTER 1
 ///////////////////////////////////////////////////////////////////////////////
-// define PERFORMING_WRITE_BLOOM if you want STM uses Bloom filters for write set
+// define PERFORMING_WRITE_BLOOM if you want STM uses Bloom filters for write set
 #define PERFORMING_WRITE_BLOOM 1
 
 #ifdef USE_BLOOM_FILTER
@@ -133,16 +133,16 @@
 ///////////////////////////////////////////////////////////////////////////////
 // OPTIMIZATIONS: MAPS AND SETS
 ///////////////////////////////////////////////////////////////////////////////
-// define MAP_WRITE_CONTAINER if you want STM uses flat map for write map
+// define MAP_WRITE_CONTAINER if you want STM uses flat map for write map
 #define MAP_WRITE_CONTAINER 1
 ///////////////////////////////////////////////////////////////////////////////
-// define MAP_NEW_CONTAINER if you want STM uses flat map for new set
+// define MAP_NEW_CONTAINER if you want STM uses flat map for new set
 //#define MAP_NEW_CONTAINER 1
 ///////////////////////////////////////////////////////////////////////////////
-// define MAP_THREAD_MUTEX_CONTAINER if you want STM uses flat map for thread mutex set
+// define MAP_THREAD_MUTEX_CONTAINER if you want STM uses flat map for thread mutex set
 //#define MAP_THREAD_MUTEX_CONTAINER 1
 ///////////////////////////////////////////////////////////////////////////////
-// define MAP_THREAD_BOOL_CONTAINER if you want STM uses flat map for thread bool set
+// define MAP_THREAD_BOOL_CONTAINER if you want STM uses flat map for thread bool set
 #define MAP_THREAD_BOOL_CONTAINER 1
 
 ///////////////////////////////////////////////////////////////////////////////

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-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -91,7 +91,7 @@
         ::new (p) cache<T>(*static_cast<cache<T> const*>(this));
         return p;
         //~ return make_cache(*this, t);
-
+
     }
 #else
     static cache<T>* make_cache(cache<T> const& rhs, transaction& ) {

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-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -311,12 +311,12 @@
    // Lock Aware Transactional Memory support methods
    //--------------------------------------------------------------------------
 
-
- template <typename M>
+
+ template <typename M>
    static void lock(M& m, latm::mutex_type& lock);
- template <typename M>
+ template <typename M>
    static bool try_lock(M& m, latm::mutex_type& lock);
- template <typename M>
+ template <typename M>
    static void unlock(M& m, latm::mutex_type& lock);
 
    //--------------------------------------------------------------------------
@@ -521,28 +521,34 @@
    template <typename T> T* write_ptr(T* in)
    {
       if (0 == in) return 0;
- return &write_poly<T,static_poly>(*in);
+ return &write_poly<static_poly>(*in);
    }
- template <typename T> T& w(T& in) { return write_poly<T,static_poly>(in); }
+ template <typename T> T& w(T& in) { return write_poly<static_poly>(in); }
    template <typename T>
    inline T& write(T& in)
    {
- return write_poly<T,static_poly>(in);
+ return write_poly<static_poly>(in);
    }
 
    template <typename T> T* write_ptr_dyn(T* in)
    {
       if (0 == in) return 0;
- return &write_poly<T,dyn_poly>(*in);
+ return &write_poly<dyn_poly>(*in);
    }
    template <typename T>
    inline T& write_dyn(T& in)
    {
- return write_poly<T,dyn_poly>(in);
+ return write_poly<dyn_poly>(in);
    }
-
+
    //--------------------------------------------------------------------------
- template <typename T, typename Poly>
+ template <typename Poly, typename T>
+ T* write_ptr_poly(T* in)
+ {
+ if (0 == in) return 0;
+ return &write_poly<Poly>(*in);
+ }
+ template <typename Poly, typename T>
    inline T& write_poly(T& in)
    {
       if (direct_updating())
@@ -1070,7 +1076,7 @@
          deletedMemoryList().push_back(detail::make_non_tx(in));
       }
    }
-
+
    //--------------------------------------------------------------------------
    template <typename T>
    void direct_delete_tx_array(T *in, std::size_t size)
@@ -1518,49 +1524,49 @@
    //--------------------------------------------------------------------------
    // deferred updating locking methods
    //--------------------------------------------------------------------------
- template <typename M>
+ template <typename M>
    static void def_full_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static bool def_full_try_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static void def_full_unlock(M& m, latm::mutex_type& mutex);
 
- template <typename M>
+ template <typename M>
    static void def_tm_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static bool def_tm_try_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static void def_tm_unlock(M& m, latm::mutex_type& mutex);
 
- template <typename M>
+ template <typename M>
    static void def_tx_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static bool def_tx_try_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static void def_tx_unlock(M& m, latm::mutex_type& mutex);
 
    //--------------------------------------------------------------------------
    // direct updating locking methods
    //--------------------------------------------------------------------------
- template <typename M>
+ template <typename M>
    static void dir_full_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static bool dir_full_try_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static void dir_full_unlock(M& m, latm::mutex_type& mutex);
 
- template <typename M>
+ template <typename M>
    static void dir_tm_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static bool dir_tm_try_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static void dir_tm_unlock(M& m, latm::mutex_type& mutex);
 
- template <typename M>
+ template <typename M>
    static void dir_tx_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static bool dir_tx_try_lock(M& m, latm::mutex_type& mutex);
- template <typename M>
+ template <typename M>
    static void dir_tx_unlock(M& m, latm::mutex_type& mutex);
 
    //--------------------------------------------------------------------------
@@ -2138,11 +2144,11 @@
 
 inline transaction* current_transaction() {return transaction::current_transaction();}
 
-template <typename M>
+template <typename M>
 inline void lock(M& m, latm::mutex_type& lock) {transaction::lock(m, lock);}
 template <typename M>
 inline bool try_lock(M& m, latm::mutex_type& lock) {return transaction::try_lock(m, lock);}
-template <typename M>
+template <typename M>
 inline void unlock(M& m, latm::mutex_type& lock) {transaction::unlock(m, lock);}
 
 
@@ -2184,7 +2190,7 @@
     #endif
         }
 }
-#endif
+#endif
 
 inline void cache_release(base_transaction_object* ptr) {
     if (ptr==0) return ;

Modified: sandbox/stm/branches/vbe/boost/stm/tx/mixin.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/mixin.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/mixin.hpp 2010-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -39,31 +39,31 @@
     typedef T value_type;
     //-----------------------------------------------------------------------------
     mixin() : val_() {
- //std::cerr << __LINE__ << " mixin val_=" << val_ << std::endl;
+ //std::cerr << __LINE__ << " mixin val_=" << val_ << std::endl;
     }
 
     mixin(mixin const& r) : val_(r.value()) {
- //std::cerr << __LINE__ << " mixin val_=" << val_ << std::endl;
+ //std::cerr << __LINE__ << " mixin val_=" << val_ << std::endl;
     }
     template<typename F, typename U>
     mixin(mixin<F,U> const& r) : val_(r.value()) {
- //std::cerr << __LINE__ << " mixin val_=" << val_ << std::endl;
+ //std::cerr << __LINE__ << " mixin val_=" << val_ << std::endl;
     }
 
     mixin(T v) : val_(v) {
- //std::cerr << __LINE__ << " mixin val_=" << v << std::endl;
+ //std::cerr << __LINE__ << " mixin val_=" << v << std::endl;
     }
     // contructor from a convertible to T
     template <typename U>
     mixin(U v) : val_(v) {
- //std::cerr << __LINE__ << " mixin val_=" << v << std::endl;
+ //std::cerr << __LINE__ << " mixin val_=" << v << std::endl;
     }
-
+
     operator T() const { return value(); }
     operator T&() { return ref(); }
 
     //-----------------------------------------------------------------------------
- // accessors
+ // accessors
     T& ref() {
         transaction* tx=current_transaction();
         if (tx!=0) {

Modified: sandbox/stm/branches/vbe/boost/stm/tx/object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/object.hpp 2010-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -34,22 +34,22 @@
     typedef mixin< object<T>, T > base_type;
     //-----------------------------------------------------------------------------
     object() : base_type() {
- //std::cerr << __LINE__ << " object" << std::endl;
+ //std::cerr << __LINE__ << " object" << std::endl;
     }
     template<typename U>
     object(object<U> const& r) : base_type(r) {
- //std::cerr << __LINE__ << " object" << std::endl;
+ //std::cerr << __LINE__ << " object" << std::endl;
     }
     object(object const& r) : base_type(r) {
- //std::cerr << __LINE__ << " object" << std::endl;
+ //std::cerr << __LINE__ << " object" << std::endl;
     }
     // contructor from a convertible to T
     template <typename U>
     object(U v) : base_type(v) {
- //std::cerr << __LINE__ << " object" << std::endl;
+ //std::cerr << __LINE__ << " object" << std::endl;
     }
     object(T v) : base_type(v) {
- //std::cerr << __LINE__ << " object" << std::endl;
+ //std::cerr << __LINE__ << " object" << std::endl;
     }
 };
 

Modified: sandbox/stm/branches/vbe/boost/stm/tx/pointer.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/pointer.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/pointer.hpp 2010-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -28,42 +28,42 @@
 // Note: the sizeof(pointer<T>)>>>>=sizeof(T*)
 //-----------------------------------------------------------------------------
 template <typename T>
-class pointer : public mixin< pointer<T> ,T* >
+class pointer : public mixin< pointer<T>, T* >
 {
- typedef mixin< pointer<T> , T* > base_type;
-
+ typedef mixin< pointer<T>, T* > base_type;
+
 public:
     //-----------------------------------------------------------------------------
     pointer() : base_type(static_cast<T*>(0)) {
- //std::cerr << __LINE__ << " pointer" << std::endl;
+ //std::cerr << __LINE__ << " pointer" << std::endl;
     }
     //pointer(pointer const& r) : base_type(*((base_type const*)(&r))) {
     pointer(pointer const& r) : base_type(r) {
- //std::cerr << __LINE__ << " pointer" << std::endl;
+ //std::cerr << __LINE__ << " pointer" << std::endl;
     }
     template<class U>
     pointer(pointer<U> const& r) : base_type(r) {
- //std::cerr << __LINE__ << " pointer" << std::endl;
+ //std::cerr << __LINE__ << " pointer" << std::endl;
     }
-
+
     template<class U, class V, class B>
     pointer(mixin<U, V*, B> const& rhs) : base_type(rhs.value()) {
- //std::cerr << __LINE__ << " pointer" << std::endl;
+ //std::cerr << __LINE__ << " pointer" << std::endl;
     }
 
     pointer(T* v) : base_type(v) {
- //std::cerr << __LINE__ << " pointer" << std::endl;
+ //std::cerr << __LINE__ << " pointer" << std::endl;
     }
     template <typename U>
     pointer(U* v) : base_type(v) {
- //std::cerr << __LINE__ << " pointer" << std::endl;
+ //std::cerr << __LINE__ << " pointer" << std::endl;
     }
 
     template<class U, class V, class B>
     pointer& operator=(mixin<U, V*, B> const& rhs) {
         this->val_=rhs.value();
     };
-
+
     T* operator->() const {
         return this->value();
     }

Modified: sandbox/stm/branches/vbe/boost/stm/tx/shallow_transaction_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/shallow_transaction_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/shallow_transaction_object.hpp 2010-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -38,7 +38,7 @@
  template <class T>
  struct has_shallow_copy_semantics : boost::mpl::false_
  {};
-
+
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------

Modified: sandbox/stm/branches/vbe/boost/stm/tx/trivial_transaction_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/trivial_transaction_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/trivial_transaction_object.hpp 2010-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -39,7 +39,7 @@
 struct has_trivial_copy_semantics :
    boost::mpl::and_<
         boost::has_trivial_copy_constructor<T>,
- boost::has_trivial_assign<T>
+ boost::has_trivial_assign<T>
>
  {};
 
@@ -54,7 +54,7 @@
 // transaction object mixin making a trivial memcpy copy
 // Provides the definition of the virtual functions
 // make_cache: use memcpy on cache_allocated
-// copy_cache: use memcpy
+// copy_cache: use memcpy
 // move_state and
 // delete_cache: use cache_allocated
 // Defines in addition the functions new and delete when USE_STM_MEMORY_MANAGER is defined

Modified: sandbox/stm/branches/vbe/boost/stm/tx_ptr.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx_ptr.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx_ptr.hpp 2010-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -22,13 +22,13 @@
 //-----------------------------------------------------------------------------
 namespace boost { namespace stm {
 
-template <typename T>
+template <typename T, typename Poly=static_poly>
 class write_ptr;
 
-template <typename T>
+template <typename T, typename Poly=static_poly>
 class read_ptr
 {
- typedef read_ptr<T> this_type;
+ typedef read_ptr<T, Poly> this_type;
 public:
 
    inline read_ptr(transaction &t, T const &tx_obj) :
@@ -39,17 +39,17 @@
       t_(t), tx_ptr_(const_cast<T*>(t_.read_ptr(tx_ptr))), written_(false)
    {}
 
- inline read_ptr<T> & operator=(read_ptr<T> const& rhs) { // never throws
+ inline read_ptr<T,Poly> & operator=(read_ptr<T,Poly> const& rhs) { // never throws
         if (this!=&rhs) {
             tx_ptr_=rhs.tx_ptr_;
         }
         return *this;
     }
- inline read_ptr<T> & operator=(T const * ptr) { // never throws
+ inline read_ptr<T,Poly> & operator=(T const * ptr) { // never throws
         tx_ptr_=const_cast<T*>(ptr);
         return *this;
     }
-
+
    T* get() const
    {
       if (t_.forced_to_abort())
@@ -99,7 +99,7 @@
       }
       else
       {
- tx_ptr_ = &t_.write(*tx_ptr_);
+ tx_ptr_ = t_.write_ptr_poly<Poly>(tx_ptr_);
          written_ = true;
       }
 
@@ -111,35 +111,35 @@
     inline operator unspecified_bool_type() const {
         return tx_ptr_ == 0? 0: &this_type::tx_ptr_;
     }
-
+
 private:
 
    mutable transaction &t_;
    mutable T *tx_ptr_;
    mutable bool written_;
- template <typename X> friend class write_ptr;
+ template <typename X, typename P> friend class write_ptr;
 };
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-template <typename T>
+template <typename T, typename Poly>
 class write_ptr
 {
 public:
 
    inline write_ptr(transaction &t, T & tx_obj) :
- t_(t), tx_obj_(t_.write(tx_obj))
+ t_(t), tx_obj_(t_.write_poly<Poly>(tx_obj))
    {}
 
    inline write_ptr(transaction &t, T* ptr) :
- t_(t), tx_obj_(*t_.write_ptr(ptr))
+ t_(t), tx_obj_(*t_.write_ptr_poly<Poly>(ptr))
    {}
 
    inline write_ptr(transaction &t, read_ptr<T> & tx_obj) :
- t_(t), tx_obj_(*t_.write_ptr(tx_obj.tx_ptr_))
+ t_(t), tx_obj_(*t_.write_ptr_poly<Poly>(tx_obj.tx_ptr_))
    {}
 
- inline write_ptr(read_ptr<T> & ptr) :
+ inline write_ptr(read_ptr<T,Poly> & ptr) :
       t_(ptr.trans()), tx_obj_(*ptr.write_ptr())
    {}
 
@@ -147,12 +147,12 @@
         tx_obj_=*t_.write_ptr(ptr);
         return *this;
     }
- write_ptr& operator=(read_ptr<T> & tx_obj) {
- tx_obj_=*t_.write_ptr(tx_obj.tx_ptr_);
+ write_ptr& operator=(read_ptr<T,Poly> & tx_obj) {
+ tx_obj_=*t_.write_ptr_poly<Poly>(tx_obj.tx_ptr_);
         return *this;
     }
     T* get() const
- {
+ {
       if (t_.forced_to_abort())
       {
          t_.lock_and_abort();
@@ -168,27 +168,27 @@
    mutable T &tx_obj_;
 };
 
-template <typename T>
-inline write_ptr<T> make_write_ptr(transaction& tx, T const* ptr) {
- return write_ptr<T>(tx, ptr);
+template <typename Poly, typename T>
+inline write_ptr<T, Poly> make_write_ptr(transaction& tx, T const* ptr) {
+ return write_ptr<T, Poly>(tx, ptr);
 }
 
-template <typename T>
-inline write_ptr<T> make_write_ptr(transaction& tx, T* ptr) {
- return write_ptr<T>(tx, ptr);
+template <typename Poly, typename T>
+inline write_ptr<T,Poly> make_write_ptr(transaction& tx, T* ptr) {
+ return write_ptr<T, Poly>(tx, ptr);
 }
 
-template <typename T>
-inline write_ptr<T> make_write_ptr(read_ptr<T>& ptr) {
- return write_ptr<T>(ptr);
+template <typename Poly, typename T>
+inline write_ptr<T, Poly> make_write_ptr(read_ptr<T, Poly>& ptr) {
+ return write_ptr<T, Poly>(ptr);
 }
 
-template <typename T>
-void delete_ptr(transaction& tx, read_ptr<T>& ptr) {
+template <typename T, typename Poly>
+void delete_ptr(transaction& tx, read_ptr<T, Poly>& ptr) {
     delete_ptr(tx, ptr.get());
 }
-template <typename T>
-void delete_ptr(transaction& tx, write_ptr<T>& ptr) {
+template <typename T, typename Poly>
+void delete_ptr(transaction& tx, write_ptr<T, Poly>& ptr) {
     delete_ptr(tx, ptr.get());
 }
 }}

Modified: sandbox/stm/branches/vbe/boost/stm/txw/transactional_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/txw/transactional_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/txw/transactional_object.hpp 2010-01-10 15:40:00 EST (Sun, 10 Jan 2010)
@@ -85,7 +85,7 @@
         value = r.value;
         return *this;
     }
-
+
 
 #if BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER
     static transactional_object<T>* make_cache(transactional_object<T> const& rhs, transaction& t) {


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