Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57118 - in sandbox/stm/branches/vbe: boost/stm boost/stm/detail boost/stm/tx libs/stm/test
From: vicente.botet_at_[hidden]
Date: 2009-10-23 15:04:56


Author: viboes
Date: 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
New Revision: 57118
URL: http://svn.boost.org/trac/boost/changeset/57118

Log:
TBoost.STM vbe: Cleanup

Removed:
   sandbox/stm/branches/vbe/boost/stm/TBRbase_contention_manager.hpp
   sandbox/stm/branches/vbe/boost/stm/TBRmove.hpp
   sandbox/stm/branches/vbe/boost/stm/TBRselect_contention_manager.hpp
   sandbox/stm/branches/vbe/boost/stm/TBRshallow_transaction_object.hpp
   sandbox/stm/branches/vbe/boost/stm/TBRtransactional_object.hpp
   sandbox/stm/branches/vbe/boost/stm/detail/TBRauto_lock.hpp
   sandbox/stm/branches/vbe/boost/stm/synchro2.hpp
   sandbox/stm/branches/vbe/boost/stm/tx/TBRsmart_ptr.hpp
Text files modified:
   sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 | 2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)

Deleted: sandbox/stm/branches/vbe/boost/stm/TBRbase_contention_manager.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/TBRbase_contention_manager.hpp 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
+++ (empty file)
@@ -1,74 +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_BASE_CONTENTION_MANAGER__HPP
-#define BOOST_STM_BASE_CONTENTION_MANAGER__HPP
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-#include <list>
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-#include <boost/stm/detail/config.hpp>
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-namespace boost { namespace stm {
-
-//-----------------------------------------------------------------------------
-// forward declarations
-//-----------------------------------------------------------------------------
-class transaction;
-class base_transaction_object;
-
-//-----------------------------------------------------------------------------
-class base_contention_manager
-{
-public:
- virtual void abort_on_new(transaction const &t) = 0;
- virtual void abort_on_delete(transaction const &t,
- base_transaction_object const &in) = 0;
-
- virtual void abort_on_read(transaction const &t,
- base_transaction_object const &in) = 0;
- virtual void abort_on_write(transaction &t,
- base_transaction_object const &in) = 0;
-
- virtual bool abort_before_commit(transaction const &t) = 0;
-
- virtual bool permission_to_abort
- (transaction const &lhs, transaction const &rhs) = 0;
-
- virtual bool permission_to_abort
- (transaction const &lhs, std::list<transaction*> &rhs)
- { return true; }
-
- virtual bool allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
- bool txIsIrrevocable, transaction const &rhs) = 0;
-
- virtual int lock_sleep_time() { return 10; }
-
- virtual void perform_isolated_tx_wait_priority_promotion(transaction &) = 0;
- virtual void perform_irrevocable_tx_wait_priority_promotion(transaction &) = 0;
-
- virtual ~base_contention_manager() {};
-};
-
-
-} // namespace core
-}
-#endif // BOOST_STM_BASE_CONTENTION_MANAGER__HPP
-
-

Deleted: sandbox/stm/branches/vbe/boost/stm/TBRmove.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/TBRmove.hpp 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
+++ (empty file)
@@ -1,46 +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_MOVE__HPP
-#define BOOST_STM_MOVE__HPP
-
-//-----------------------------------------------------------------------------
-#include <boost/stm/detail/config.hpp>
-//-----------------------------------------------------------------------------
-#if BUILD_MOVE_SEMANTICS
-#include <type_traits>
-#endif
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-namespace boost { namespace stm {
-
-#if BUILD_MOVE_SEMANTICS
-bool const kDracoMoveSemanticsCompiled = true;
-#else
-bool const kDracoMoveSemanticsCompiled = false;
-#endif
-
-#if BUILD_MOVE_SEMANTICS
-template <class T>
-inline typename std::remove_reference<T>::type&& draco_move(T &&t)
-{
- return t;
-}
-#endif
-
-} // namespace core
-}
-#endif // BOOST_STM_DATATYPES__HPP
-
-

Deleted: sandbox/stm/branches/vbe/boost/stm/TBRselect_contention_manager.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/TBRselect_contention_manager.hpp 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
+++ (empty file)
@@ -1,145 +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_SELECT_CONTENTION_MANAGER__HPP
-#define BOOST_STM_SELECT_CONTENTION_MANAGER__HPP
-
-//-----------------------------------------------------------------------------
-#include <boost/stm/detail/config.hpp>
-//-----------------------------------------------------------------------------
-
-#if defined(BOOST_STM_CM_STATIC_CONF)
-#if defined(BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm)
-#include <boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp>
-#else
-#include BOOST_STM_CM_STATIC_CONF
-//#include <boost/stm/contention_managers/default.hpp>
-#endif
-#else
-#if defined(BOOST_STM_CM_DYNAMIC_CONF)
-#include <boost/stm/contention_managers/polymorphic.hpp>
-#endif
-#endif
-
-namespace boost { namespace stm {
-
-
-#if defined(BOOST_STM_CM_STATIC_CONF)
- inline static contention_manager_type* get_contention_manager() {
- static contention_manager_type cm_;return &cm_;
- }
- inline static void cm_abort_on_new(transaction const &t) {
- return contention_manager_type::abort_on_new(t);
- }
- inline static void cm_abort_on_delete(transaction const &t,
- base_transaction_object const &in) {
- return contention_manager_type::abort_on_delete(t,in);
- }
-
- inline static void cm_abort_on_read(transaction const &t,
- base_transaction_object const &in) {
- return contention_manager_type::abort_on_read(t,in);
- }
- inline static void cm_abort_on_write(transaction &t,
- base_transaction_object const &in) {
- return contention_manager_type::abort_on_write(t,in);
- }
-
- inline static bool cm_abort_before_commit(transaction const &t) {
- return contention_manager_type::abort_before_commit(t);
- }
-
- inline static bool cm_permission_to_abort(transaction const &lhs, transaction const &rhs) {
- return contention_manager_type::permission_to_abort(lhs,rhs);
- }
-
- inline static bool cm_permission_to_abort(transaction const &lhs, std::list<transaction*> &rhs) {
- return contention_manager_type::permission_to_abort(lhs,rhs);
- }
-
- inline static bool cm_allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
- bool txIsIrrevocable, transaction const &rhs) {
- return contention_manager_type::allow_lock_to_abort_tx(lockWaitTime,lockAborted,txIsIrrevocable,rhs);
- }
-
- inline static int cm_lock_sleep_time() {
- return contention_manager_type::lock_sleep_time();
- }
-
- inline static void cm_perform_isolated_tx_wait_priority_promotion(transaction &t) {
- return contention_manager_type::perform_isolated_tx_wait_priority_promotion(t);
- }
- inline static void cm_perform_irrevocable_tx_wait_priority_promotion(transaction &t) {
- return contention_manager_type::perform_irrevocable_tx_wait_priority_promotion(t);
- }
-
-#else
- struct poly_contention_manager {
- static base_contention_manager *cm_;
- };
- inline static void contention_manager(base_contention_manager *rhs) {
- delete poly_contention_manager::cm_; poly_contention_manager::cm_ = rhs;
- }
- inline static base_contention_manager* get_contention_manager() {
- return poly_contention_manager::cm_;
- }
- inline static base_contention_manager* get_cm() {
- return poly_contention_manager::cm_;
- }
-
- inline static void cm_abort_on_new(transaction const &t) {
- return get_cm()->abort_on_new(t);
- }
- inline static void cm_abort_on_delete(transaction const &t, base_transaction_object const &in) {
- return get_cm()->abort_on_delete(t,in);
- }
-
- inline static void cm_abort_on_read(transaction const &t, base_transaction_object const &in) {
- return get_cm()->abort_on_read(t,in);
- }
- inline static void cm_abort_on_write(transaction &t, base_transaction_object const &in) {
- return get_cm()->abort_on_write(t,in);
- }
-
- inline static bool cm_abort_before_commit(transaction const &t) {
- return get_cm()->abort_before_commit(t);
- }
-
- inline static bool cm_permission_to_abort(transaction const &lhs, transaction const &rhs) {
- return get_cm()->permission_to_abort(lhs,rhs);
- }
-
- inline static bool cm_permission_to_abort(transaction const &lhs, std::list<transaction*> &rhs) {
- return get_cm()->permission_to_abort(lhs,rhs);
- }
-
- inline static bool cm_allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
- bool txIsIrrevocable, transaction const &rhs) {
- return get_cm()->allow_lock_to_abort_tx(lockWaitTime,lockAborted,txIsIrrevocable,rhs); }
-
- inline static int cm_lock_sleep_time() {
- return get_cm()->lock_sleep_time();
- }
-
- inline static void cm_perform_isolated_tx_wait_priority_promotion(transaction &t) {
- return get_cm()->perform_isolated_tx_wait_priority_promotion(t);
- }
- inline static void cm_perform_irrevocable_tx_wait_priority_promotion(transaction &t) {
- return get_cm()->perform_irrevocable_tx_wait_priority_promotion(t);
- }
-
-#endif
-
-
-}}
-#endif // CONTENTION_MANAGER_H

Deleted: sandbox/stm/branches/vbe/boost/stm/TBRshallow_transaction_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/TBRshallow_transaction_object.hpp 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
+++ (empty file)
@@ -1,167 +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_SHALLOW_TRANSACTION_OBJECT__HPP
-#define BOOST_STM_SHALLOW_TRANSACTION_OBJECT__HPP
-
-//-----------------------------------------------------------------------------
-//#include <stdarg.h>
-#include <pthread.h>
-//-----------------------------------------------------------------------------
-#include <list>
-//-----------------------------------------------------------------------------
-#include <boost/stm/detail/config.hpp>
-//-----------------------------------------------------------------------------
-#include <boost/stm/base_transaction_object.hpp>
-#include <boost/stm/cache_fct.hpp>
-#include <boost/stm/datatypes.hpp>
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-namespace boost { namespace stm {
-
-//-----------------------------------------------------------------------------
-// forward declarations
-//-----------------------------------------------------------------------------
-class transaction;
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-// transaction object mixin making shallow copy
-// Provides the definition of the virtual functions
-// clone: use copy constructor
-// copy_state: use assignement
-// move_state and
-// cache_deallocate: use delete
-// Defines in addition the functions new and delete when USE_STM_MEMORY_MANAGER is defined
-
-// The parameter Base=base_transaction_object allows to mic transaction_object and polymorphism
-// class B : transaction_object<B> {}
-// class D : transaction_object<D, B> {}
-// the single issue is the forward constructors from transaction_object<D, B> to B
-//-----------------------------------------------------------------------------
-
-template <class Derived, typename Base=base_transaction_object>
-class shallow_transaction_object : public base_transaction_object
-{
-public:
-
- //--------------------------------------------------------------------------
- virtual base_transaction_object* clone(transaction* t) const {
- Derived* tmp = cache_clone(t, *static_cast<Derived const*>(this));
- return tmp;
- }
-
- //--------------------------------------------------------------------------
- virtual void cache_deallocate() {
- boost::stm::cache_deallocate(this);
- }
-
- //--------------------------------------------------------------------------
- virtual void copy_state(base_transaction_object const * const rhs)
- {
- boost::stm::cache_copy(static_cast<Derived const * const>(rhs), static_cast<Derived *>(this));
- }
-
-#if BUILD_MOVE_SEMANTICS
- virtual void move_state(base_transaction_object * rhs)
- {
- static_cast<Derived &>(*this) = draco_move
- (*(static_cast<Derived*>(rhs)));
- }
-#endif
-
-
-#if USE_STM_MEMORY_MANAGER
- void* operator new(std::size_t size, const std::nothrow_t&) throw ()
- {
- return retrieve_mem(size);
- }
- void* operator new(std::size_t size) throw (std::bad_alloc)
- {
- void* ptr= retrieve_mem(size);
- if (ptr==0) throw std::bad_alloc;
- return ptr;
- }
-
- void operator delete(void* mem) throw ()
- {
- static Derived elem;
- static std::size_t elemSize = sizeof(elem);
- return_mem(mem, elemSize);
- }
-#endif
-
-};
-
-template <typename T> class shallow_native_trans :
-public shallow_transaction_object< shallow_native_trans<T> >
-{
-public:
-
- shallow_native_trans() : value_(T()) {}
- shallow_native_trans(T const &rhs) : value_(rhs) {}
- shallow_native_trans(shallow_native_trans const &rhs) : value_(rhs.value_) {}
- ~shallow_native_trans() {}
-
- shallow_native_trans& operator=(T const &rhs) { value_ = rhs; return *this; }
-
- shallow_native_trans& operator--() { --value_; return *this; }
- shallow_native_trans operator--(int) { shallow_native_trans n = *this; --value_; return n; }
-
- shallow_native_trans& operator++() { ++value_; return *this; }
- shallow_native_trans operator++(int) { shallow_native_trans n = *this; ++value_; return n; }
-
- shallow_native_trans& operator+=(T const &rhs)
- {
- value_ += rhs;
- return *this;
- }
-
- shallow_native_trans operator+(shallow_native_trans const &rhs)
- {
- shallow_native_trans ret = *this;
- ret.value_ += rhs.value_;
- return ret;
- }
-
- //template <>
- operator T() const
- {
- return this->value_;
- }
-
-#if BUILD_MOVE_SEMANTICS
- //--------------------------------------------------
- // move semantics
- //--------------------------------------------------
- shallow_native_trans(shallow_native_trans &&rhs) { value_ = rhs.value_;}
- shallow_native_trans& operator=(shallow_native_trans &&rhs)
- { value_ = rhs.value_; return *this; }
-#endif
-
- T& value() { return value_; }
- T const & value() const { return value_; }
-
-private:
- T value_;
-};
-
-}}
-#endif // BOOST_STM_SHALLOW_TRANSACTION_OBJECT__HPP
-
-

Deleted: sandbox/stm/branches/vbe/boost/stm/TBRtransactional_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/TBRtransactional_object.hpp 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
+++ (empty file)
@@ -1,228 +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_TRANSACTIONAL_OBJECT__HPP
-#define BOOST_STM_TRANSACTIONAL_OBJECT__HPP
-
-#include <boost/stm/base_transaction.hpp>
-
-//-----------------------------------------------------------------------------
-namespace boost { namespace stm {
-
-//-----------------------------------------------------------------------------
-// transactional object wrapper
-// A transactional_object<T> is a base_transaction_object wrapping an instance of type T
-// Provides the definition of the virtual functions
-// forward constructors to the wrapped type
-// copy_state: relaying on the cache_copy<T> generic function
-// move_state and
-// cache_deallocate: relaying on the cache_copy<T> generic function
-// Defines in addition the functions new and delete when USE_STM_MEMORY_MANAGER is defined
-//
-// If a class D inherits from B we have that transactional_object<D> dont inherits from transactional_object<B>, but
-// we can static/dynamic cast them robustly.
-// Evidently the std::static_cast/std::dynamic_cast do not works. We need to define the specific cast
-//
-// transactional_object<D>* d=...;
-// transactional_object<B>* b=tx_static_cast<B>(d);
-//
-// transactional_object<B>* b=...;
-// transactional_object<D>* d=tx_dynamic_cast<B>(b);
-//
-//-----------------------------------------------------------------------------
-
-template <typename T>
-class transactional_object : public base_transaction_object {
-public:
- T value;
-
- transactional_object() {}
- transactional_object(const T*ptr)
- : base_transaction_object()
- , value(*ptr) {}
-
- transactional_object(transactional_object<T> const & r)
- : base_transaction_object(r)
- , value(r.value) {}
-
- template <typename T1>
- transactional_object(T1 const &p1)
- : base_transaction_object()
- , value(p1) {}
-
- template <typename T1, typename T2>
- transactional_object(T1 const &p1, T2 const &p2)
- : base_transaction_object()
- , value(p1,p2) {}
-
- transactional_object & operator=(transactional_object const & r) // =default never throws
- {
- value = r.value;
- return *this;
- }
-
-#if BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER
- virtual base_transaction_object* clone(transaction* t) const {
- transactional_object<T>* p = cache_allocate<transactional_object<T> >(t);
- if (p==0) {
- throw std::bad_alloc();
- }
- ::new (p) transactional_object<T>(*static_cast<transactional_object<T> const*>(this));
- return p;
- }
-#else
- virtual base_transaction_object* clone(transaction*) const {
- //return cache_clone(*this);
- return new transactional_object<T>(*this);
- }
-#endif
-
-#if BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER
- virtual void cache_deallocate() {
- static_cast<transactional_object<T>*>(this)->~transactional_object<T>();
- boost::stm::cache_deallocate(this);
- }
-#else
- virtual void cache_deallocate() {
- 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(std::size_t size, const std::nothrow_t&) throw ()
- {
- return retrieve_mem(size);
- }
- void* operator new(std::size_t size) throw (std::bad_alloc)
- {
- void* ptr= retrieve_mem(size);
- if (ptr==0) throw std::bad_alloc;
- return ptr;
- }
-
- void operator delete(void* mem) throw ()
- {
- static transactional_object<T> elem;
- static std::size_t elemSize = sizeof(elem);
- return_mem(mem, elemSize);
- }
- #endif
-
-};
-
-//-----------------------------------------------------------------------------
-// gets the transactional_object<T> pointer wrapping the T pointer
-//-----------------------------------------------------------------------------
-template <typename T>
-static transactional_object<T>* tx_up_cast(T* ptr) {
- return reinterpret_cast<transactional_object<T>*>(reinterpret_cast<char*>(ptr)-offsetof(transactional_object<T>, value));
-}
-
-//-----------------------------------------------------------------------------
-// static_cast two transactional_object's
-//-----------------------------------------------------------------------------
-template <typename T, typename U>
-static transactional_object<T>* tx_static_cast(transactional_object<U>* ptr) {
- return tx_up_cast(static_cast<T*>(&ptr->value));
-}
-
-//-----------------------------------------------------------------------------
-// dynamic_cast two transactional_object's
-//-----------------------------------------------------------------------------
-template <typename T, typename U>
-static transactional_object<T>* tx_dynamic_cast(transactional_object<U>* ptr) {
- T* p = dynamic_cast<T*>(&ptr->value);
- if (p==0) return 0;
- return tx_up_cast(p);
-}
-
-
-
-#ifdef BOOST_STM_USE_MEMCOPY
-#ifdef BOOST_STM_NO_PARTIAL_SPECIALIZATION
-namespace partial_specialization_workaround {
-
-template <class T, class A>
-struct cache_clone<transactional_object<std::vector<T,A> > > {
- static inline transactional_object<std::vector<T,A> >* apply(const transactional_object<std::vector<T,A> >& val) {
- return new transactional_object<std::vector<T,A> >(val);
- }
-};
-} // partial_specialization_workaround
-
-#else //BOOST_STM_NO_PARTIAL_SPECIALIZATION
-
-template <class T>
-inline transactional_object<std::vector<T> >* cache_clone(const transactional_object<std::vector<T> >& val) {
- return new transactional_object<std::vector<T> >(val);
-}
-
-#endif // BOOST_STM_NO_PARTIAL_SPECIALIZATION
-#endif
-
-
-
-#ifdef BOOST_STM_USE_MEMCOPY
-#ifdef BOOST_STM_NO_PARTIAL_SPECIALIZATION
-namespace partial_specialization_workaround {
-
-template <class T>
-struct cache_copy<transactional_object<std::vector<T> > > {
- static inline void apply(const transactional_object<std::vector<T> >* const ori, transactional_object<std::vector<T> >* target) {
- *target=*ori;
- }
-};
-
-} // partial_specialization_workaround
-#else
-template <class T> void cache_copy(const transactional_object<std::vector<T> >* const ori, transactional_object<std::vector<T> >* target) {
- *target=*ori;
-}
-#endif
-#endif
-
-
-#ifdef BOOST_STM_USE_MEMCOPY
-#ifdef BOOST_STM_NO_PARTIAL_SPECIALIZATION
-namespace partial_specialization_workaround {
-
-template <class T>
-struct cache_deallocate<transactional_object<std::vector<T> > > {
- static void apply(transactional_object<std::vector<T> >* ptr) {
- delete ptr;
- }
-};
-
-}
-
-#else //!BOOST_STM_NO_PARTIAL_SPECIALIZATION
-
-template <class T>
-inline void cache_deallocate(transactional_object<std::vector<T> >* ptr) {
- delete ptr;
-}
-
-#endif //BOOST_STM_NO_PARTIAL_SPECIALIZATION
-#endif // BOOST_STM_USE_MEMCOPY
-
-
-} // namespace core
-}
-#endif // BASE_TRANSACTION_H
-
-

Deleted: sandbox/stm/branches/vbe/boost/stm/detail/TBRauto_lock.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/TBRauto_lock.hpp 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
+++ (empty file)
@@ -1,234 +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_AUTO_LOCK_H
-#define BOOST_STM_AUTO_LOCK_H
-
-//---------------------------------------------------------------------------
-#include <pthread.h>
-#include <stdexcept>
-//---------------------------------------------------------------------------
-#include <string>
-#include <iostream>
-#include <map>
-#include <vector>
-//---------------------------------------------------------------------------
-#include <boost/stm/detail/config.hpp>
-//---------------------------------------------------------------------------
-#include <boost/stm/datatypes.hpp>
-#ifdef PERFORMING_LATM
-#include <boost/stm/transaction.hpp>
-#else
-#endif
-//---------------------------------------------------------------------------
-
-
-//---------------------------------------------------------------------------
-#ifdef PERFORMING_LATM
-#define BOOST_STM_LOCK(a) boost::stm::transaction::lock_(a)
-#define BOOST_STM_UNLOCK(a) boost::stm::transaction::unlock_(a)
-#else
-#define BOOST_STM_LOCK(a) boost::synchro::lock(a)
-#define BOOST_STM_UNLOCK(a) boost::synchro::unlock(a)
-#endif
-
-//---------------------------------------------------------------------------
-namespace boost { namespace stm {
-
-
-//---------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-class timer_lock_exception : public std::exception
-{
-public:
- timer_lock_exception(char const * const what) : what_(what) {}
-
- //virtual char const * what() const { return what_; }
-
-private:
- char const * const what_;
-};
-
-
-typedef timer_lock_exception timer_err;
-
-//---------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-class auto_lock
-{
-public:
- typedef std::pair<thread_id_t const, Mutex*> ThreadedLockPair;
- typedef std::multimap<thread_id_t const, Mutex*> ThreadedLockContainer;
- typedef ThreadedLockContainer::iterator ThreadedLockIter;
-
- auto_lock(Mutex &mutex) : hasLock_(false), lock_(0)
- {
- do_auto_lock(&mutex);
- }
-
- auto_lock(Mutex *mutex) : hasLock_(false), lock_(0)
- {
- do_auto_lock(mutex);
- }
-
-
- auto_lock(milliseconds_t timeOut, Mutex &mutex) : hasLock_(false), lock_(0)
- {
- do_timed_auto_lock(timeOut, &mutex);
- }
-
- auto_lock(milliseconds_t timeOut, Mutex *mutex) : hasLock_(false), lock_(0)
- {
- do_timed_auto_lock(timeOut, mutex);
- }
-
- ~auto_lock() { do_auto_unlock(); }
-
- bool has_lock() { return hasLock_; }
-
- void release_lock() { do_auto_unlock(); }
-
- static int VC6_fix()
- {
- static int VC6_fix = 0;
- return VC6_fix;
- }
-
-private:
-
- void do_timed_auto_lock(milliseconds_t timeOut, Mutex *mutex)
- {
- lock_ = mutex;
-
- if (thread_has_lock(mutex)) return;
-
- for (milliseconds_t i = 0; i < timeOut; ++i)
- {
- if (synchro::try_lock(*lock_))
- {
- hasLock_ = true;
- insert_into_threaded_lock_map(mutex);
- return;
- }
-
- SLEEP(1);
- }
-
- throw timer_lock_exception( "lock timed out" );
- }
-
- void insert_into_threaded_lock_map(Mutex* mutex)
- {
- synchro::lock_guard<Mutex> lock_i(*global_lock());
- threaded_locks().insert(ThreadedLockPair(this_thread::get_id(), mutex));
- }
-
- void do_auto_lock(Mutex *mutex)
- {
- lock_ = mutex;
- if (thread_has_lock(mutex)) return;
-
- BOOST_STM_LOCK(mutex);
- hasLock_ = true;
-
- insert_into_threaded_lock_map(mutex);
- }
-
- void do_auto_unlock()
- {
- if (hasLock_)
- {
- hasLock_ = false;
- BOOST_STM_UNLOCK(lock_);
- remove_thread_has_lock(lock_);
- }
- }
-
- bool thread_has_lock(Mutex *rhs)
- {
- synchro::lock_guard<Mutex> lock_g(*global_lock());
-
- for (ThreadedLockIter i = threaded_locks().begin();
- i != threaded_locks().end(); ++i)
- {
- if (i->first == this_thread::get_id() && i->second == rhs)
- {
- return true;
- }
- }
-
- return false;
- }
-
- void remove_thread_has_lock(Mutex *rhs)
- {
- synchro::lock_guard<Mutex> lock_g(*global_lock());
-
- for (ThreadedLockIter i = threaded_locks().begin();
- i != threaded_locks().end(); ++i)
- {
- if (i->first == this_thread::get_id() && i->second == rhs)
- {
- threaded_locks().erase(i);
- break;
- }
- }
- }
-
- static Mutex *global_lock()
- {
-#ifndef BOOST_STM_USE_BOOST_MUTEX
- static Mutex globalLock = PTHREAD_MUTEX_INITIALIZER;
-#else
- static Mutex globalLock;
-#endif
- return &globalLock;
- }
-
- static ThreadedLockContainer &threaded_locks()
- {
- static ThreadedLockContainer localThreadedLocks;
- return localThreadedLocks;
- }
-
- //auto_lock(auto_lock const &);
- //auto_lock& operator=(auto_lock const &);
-
- bool hasLock_;
- Mutex *lock_;
-};
-
-//---------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-#define use_lock(L) if (bool __end=false); else \
- for (boost::stm::auto_lock ___l(L); !__end; __end=true)
-#define use_timed_lock(T, L) if (bool __end=false); else \
- for (boost::stm::auto_lock ___l(T, L); !__end; __end=false)
-#define try_timed_lock(T, L) if (bool __end=false); else \
- try { for (boost::stm::auto_lock ___l(T, L); !__end; __end=false)
-
-#define catch_lock_timeout(E) } catch (std::timer_lock_exception &E)
-#define lock_timeout } catch (std::timer_lock_exception &E)
-
-}}
-
-#endif // BOOST_STM_AUTO_LOCK_H
-
-
-
-
-
-
-
-
-

Deleted: sandbox/stm/branches/vbe/boost/stm/synchro2.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synchro2.hpp 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
+++ (empty file)
@@ -1,255 +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_SYNCHO__HPP
-#define BOOST_STM_SYNCHO__HPP
-
-//-----------------------------------------------------------------------------
-#include <pthread.h>
-//-----------------------------------------------------------------------------
-#include <boost/stm/detail/config.hpp>
-//-----------------------------------------------------------------------------
-#ifdef BOOST_STM_USE_BOOST_SYNCHRO
-#include <boost/synchro.hpp>
-#else
-#include <stdexcept>
-#endif
-//-----------------------------------------------------------------------------
-
-#ifndef BOOST_STM_USE_BOOST_MUTEX
- typedef pthread_mutex_t Mutex;
-#else
- typedef boost::mutex Mutex;
-#endif
-
-typedef pthread_mutex_t PLOCK;
-
-//-----------------------------------------------------------------------------
-
-namespace boost {
-#ifndef BOOST_STM_USE_BOOST_SYNCHRO
-namespace synchro {
-
- class lock_error : public std::exception
- {
- public:
- lock_error() {}
- ~lock_error() throw() {}
-
- virtual const char* what() const throw() {return "synchro::lock_error";}
- };
-
- struct defer_lock_t
- {};
- struct try_to_lock_t
- {};
- struct adopt_lock_t
- {};
-
- const defer_lock_t defer_lock={};
- const try_to_lock_t try_to_lock={};
- const adopt_lock_t adopt_lock={};
-
- template< typename Lockable >
- inline void lock(Lockable& lockable) {
- lockable.lock();
- }
-
- template< typename Lockable >
- inline void unlock(Lockable& lockable) {
- lockable.unlock();
- }
-
- template< typename Lockable >
- inline bool try_lock(Lockable& lockable) {
- return lockable.try_lock();
- }
-
- template<>
- inline void lock<pthread_mutex_t>(pthread_mutex_t& lockable) {
- pthread_mutex_lock(&lockable);
- }
-
- template<>
- inline void unlock<pthread_mutex_t>(pthread_mutex_t& lockable) {
- pthread_mutex_unlock(&lockable);
- }
-
- template<>
- inline bool try_lock<pthread_mutex_t>(pthread_mutex_t& lockable) {
- return pthread_mutex_trylock(&lockable);
- }
-
- template<typename Mutex>
- class lock_guard
- {
- private:
- Mutex& m;
-
- explicit lock_guard(lock_guard&);
- lock_guard& operator=(lock_guard&);
- public:
- explicit lock_guard(Mutex& m_)
- : m(m_)
- {
- synchro::lock(m);
- }
- lock_guard(Mutex& m_,adopt_lock_t)
- : m(m_)
- {}
- ~lock_guard()
- {
- synchro::unlock(m);
- }
- };
-
- template<typename Mutex>
- class lock_guard_if
- {
- private:
- Mutex& m;
- bool cnd_;
-
- explicit lock_guard_if(lock_guard_if&);
- lock_guard_if& operator=(lock_guard_if&);
- public:
- explicit lock_guard_if(Mutex& m_, bool cnd)
- : m(m_)
- , cnd_(cnd)
- {
- if (cnd_) synchro::lock(m);
- }
- lock_guard_if(Mutex& m_, bool cnd,adopt_lock_t)
- : m(m_)
- , cnd_(cnd)
- {}
- ~lock_guard_if()
- {
- if (cnd_) synchro::unlock(m);
- }
- };
-
- template<typename Mutex>
- class unique_lock
- {
- private:
- Mutex* m;
- bool is_locked;
- unique_lock(unique_lock&);
- unique_lock& operator=(unique_lock&);
- public:
- unique_lock():
- m(0),is_locked(false)
- {}
-
- explicit unique_lock(Mutex& m_):
- m(&m_),is_locked(false)
- {
- lock();
- }
-
- unique_lock(Mutex& m_,adopt_lock_t):
- m(&m_),is_locked(true)
- {}
- unique_lock(Mutex& m_,defer_lock_t):
- m(&m_),is_locked(false)
- {}
- unique_lock(Mutex& m_,try_to_lock_t):
- m(&m_),is_locked(false)
- {
- try_lock();
- }
- void swap(unique_lock& other)
- {
- std::swap(m,other.m);
- std::swap(is_locked,other.is_locked);
- }
-
- ~unique_lock()
- {
- if(owns_lock())
- {
- synchro::unlock(*m);
- }
- }
- void lock()
- {
- if(owns_lock())
- {
- throw lock_error();
- }
- synchro::lock(*m);
- is_locked=true;
- }
- bool try_lock()
- {
- if(owns_lock())
- {
- throw lock_error();
- }
- is_locked=synchro::try_lock(*m);
- return is_locked;
- }
- void unlock()
- {
- if(!owns_lock())
- {
- throw lock_error();
- }
- synchro::unlock(*m);
- is_locked=false;
- }
-
- typedef void (unique_lock::*bool_type)();
- operator bool_type() const
- {
- return is_locked?&unique_lock::lock:0;
- }
- bool operator!() const
- {
- return !owns_lock();
- }
- bool owns_lock() const
- {
- return is_locked;
- }
-
- Mutex* mutex() const
- {
- return m;
- }
-
- Mutex* release()
- {
- Mutex* const res=m;
- m=0;
- is_locked=false;
- return res;
- }
- };
-
- template<typename Mutex>
- void swap(unique_lock<Mutex>& lhs,unique_lock<Mutex>& rhs)
- {
- lhs.swap(rhs);
- }
-}
-#endif
-namespace stm {
-
-
-} // namespace core
-}
-#endif // BOOST_STM_SYNCHO__HPP
-
-

Deleted: sandbox/stm/branches/vbe/boost/stm/tx/TBRsmart_ptr.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/TBRsmart_ptr.hpp 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
+++ (empty file)
@@ -1,580 +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=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=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 as 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=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=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 = 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 = 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) {
- 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
- //this_type(r).swap(*this);
- transaction* tx=current_transaction();
- if (tx==0) throw "error";
- tx_=tx;
- ptr_=r.ptr_;
- written_=false;
- return *this;
- }
-
- 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");
- }
-
- // 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;
- }
- }
-
- 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;
- }
-
- 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 = 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/test/Jamfile.v2
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 2009-10-23 15:04:55 EDT (Fri, 23 Oct 2009)
@@ -99,7 +99,7 @@
             ########### fails with CHECK
             # /bin/sh: line 4: 4072 Aborted (core dumped) "bin/test_lit_def_t2.test/gcc-3.4.4/debug/threading-multi/test_lit_def_t2.exe" > "bin/test_lit_def_t2.test/gcc-3.4.4/debug/threading-multi/test_lit_def_t2.output" 2>&1
             ########### deadlock sometimes without CHECK. killed after 0:40. 00% CPU
- [ run stm : -bench lit_example -def -threads 2 -inserts 100 : : : test_lit_example_def_t2_i100 ]
+ #[ run stm : -bench lit_example -def -threads 2 -inserts 100 : : : test_lit_example_def_t2_i100 ]
 
             ########### livelock. killed after 3:50. 50% CPU
             #[ run stm : -bench nested_tx -def -threads 2 -inserts 100 : : : test_nested_tx_def_t2_i100 ]


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