|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60749 - in sandbox/stm/branches/vbe/boost/stm: . detail latm memory_managers synch tx
From: vicente.botet_at_[hidden]
Date: 2010-03-21 12:55:08
Author: viboes
Date: 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
New Revision: 60749
URL: http://svn.boost.org/trac/boost/changeset/60749
Log:
Boost.STM/vbe:
* Clean up traces
* Don't use pthread specific interfaces
* Introduce BOOST_USES_STATIC_TSS
Text files modified:
sandbox/stm/branches/vbe/boost/stm/base_transaction.hpp | 3 ++-
sandbox/stm/branches/vbe/boost/stm/base_transaction_object.hpp | 5 ++++-
sandbox/stm/branches/vbe/boost/stm/cache_fct.hpp | 4 +++-
sandbox/stm/branches/vbe/boost/stm/datatypes.hpp | 3 ++-
sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 23 ++++++++++++++++++-----
sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp | 2 +-
sandbox/stm/branches/vbe/boost/stm/detail/vector_map.hpp | 13 ++++++++-----
sandbox/stm/branches/vbe/boost/stm/detail/vector_set.hpp | 16 ++++++++--------
sandbox/stm/branches/vbe/boost/stm/language_like.hpp | 15 +++++++++------
sandbox/stm/branches/vbe/boost/stm/latm/datatypes.hpp | 4 +++-
sandbox/stm/branches/vbe/boost/stm/memory_managers/base_memory_manager.hpp | 4 +++-
sandbox/stm/branches/vbe/boost/stm/memory_managers/memory_manager.hpp | 4 +++-
sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp | 4 +++-
sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp | 3 ++-
sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 30 ++++++++++++++++++++++++------
sandbox/stm/branches/vbe/boost/stm/transaction_bookkeeping.hpp | 4 +++-
sandbox/stm/branches/vbe/boost/stm/transaction_object.hpp | 4 +++-
sandbox/stm/branches/vbe/boost/stm/tx/deep_transaction_object.hpp | 4 +++-
sandbox/stm/branches/vbe/boost/stm/tx/shallow_transaction_object.hpp | 3 ++-
sandbox/stm/branches/vbe/boost/stm/tx/trivial_transaction_object.hpp | 4 +++-
20 files changed, 107 insertions(+), 45 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 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -16,7 +16,8 @@
//-----------------------------------------------------------------------------
#include <stdarg.h>
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
//-----------------------------------------------------------------------------
#include <list>
//-----------------------------------------------------------------------------
Modified: sandbox/stm/branches/vbe/boost/stm/base_transaction_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/base_transaction_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/base_transaction_object.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -15,7 +15,9 @@
#define BOOST_STM_BASE_TRANSACTION_OBJECT__HPP
//-----------------------------------------------------------------------------
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
//-----------------------------------------------------------------------------
#include <list>
//-----------------------------------------------------------------------------
@@ -28,6 +30,7 @@
//-----------------------------------------------------------------------------
#include <boost/stm/detail/memory_pool.hpp>
+
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
Modified: sandbox/stm/branches/vbe/boost/stm/cache_fct.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/cache_fct.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/cache_fct.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -16,7 +16,9 @@
//-----------------------------------------------------------------------------
#include <stdarg.h>
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
//-----------------------------------------------------------------------------
#include <list>
//-----------------------------------------------------------------------------
Modified: sandbox/stm/branches/vbe/boost/stm/datatypes.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/datatypes.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/datatypes.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -15,7 +15,8 @@
#define BOOST_STM_DATATYPES__HPP
//-----------------------------------------------------------------------------
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
//-----------------------------------------------------------------------------
#include <cstddef>
//-----------------------------------------------------------------------------
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-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -48,7 +48,7 @@
// OTHER: each TSS data has its specific TSS
#define USE_SINGLE_THREAD_CONTEXT_MAP 1
-//~ #define BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP 1
+//#define BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP 1
///////////////////////////////////////////////////////////////////////////////
@@ -153,13 +153,26 @@
#define BOOST_STM_USE_BOOST 1
#ifdef BOOST_STM_USE_BOOST
+// Don't work yet
//~ #define BOOST_STM_BLOOM_FILTER_USE_DYNAMIC_BITSET 1
-//~ #define BOOST_STM_USE_BOOST_SLEEP 1
-//~ #define BOOST_STM_USE_BOOST_THREAD_ID 1
-//~ #define BOOST_STM_USE_BOOST_MUTEX 1
-//~ #define BOOST_STM_T_USE_BOOST_MUTEX 1
+#define BOOST_STM_USE_BOOST_SLEEP 1
+#define BOOST_STM_USE_BOOST_THREAD_ID 1
#endif
+#include <boost/thread/detail/platform.hpp>
+
+#if defined(BOOST_THREAD_PLATFORM_WIN32)
+#define BOOST_STM_USE_BOOST_MUTEX 1
+#define BOOST_STM_T_USE_BOOST_MUTEX 1
+#define BOOST_USES_STATIC_TSS 1
+#elif defined(BOOST_THREAD_PLATFORM_PTHREAD)
+#define BOOST_STM_USE_BOOST_MUTEX 1
+#define BOOST_STM_T_USE_BOOST_MUTEX 1
+// Don't work yet
+//~ #define BOOST_USES_STATIC_TSS 1
+#else
+#error "Boost threads unavailable on this platform"
+#endif
///////////////////////////////////////////////////////////////////////////////
// COMPILERS DEPENDENT
///////////////////////////////////////////////////////////////////////////////
Modified: sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -321,7 +321,7 @@
for (tss_context_map_type::iterator i = tss_context_map_.begin();
i != tss_context_map_.end(); ++i)
{
- BOOST_ASSERT(i->secondi!=0);
+ BOOST_ASSERT(i->second!=0);
if (i->first == threadId) continue;
synchro::lock(i->second->mutex_ BOOST_STM_CALL_CONTEXT("mutex")); // INSTANCE
Modified: sandbox/stm/branches/vbe/boost/stm/detail/vector_map.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/vector_map.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/vector_map.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -53,7 +53,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
- typename vector_map<T,U>::iterator find(first_t const &t)
+ iterator find(first_t const &t)
{
for (typename vector_map<T,U>::iterator i = pairs_.begin(); i != pairs_.end(); ++i)
{
@@ -65,11 +65,12 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
- typename vector_map<T,U>::iterator insert(cont_pair const &wp)
+ iterator insert(cont_pair const &wp)
{
T const &f = wp.first;
-
- for (typename vector_map<T,U>::iterator i = pairs_.begin(); i != pairs_.end(); ++i)
+
+ iterator prev;
+ for (iterator i = pairs_.begin(); i != pairs_.end(); ++i)
{
if (f == i->first)
{
@@ -79,7 +80,9 @@
}
pairs_.push_back(wp);
- return (typename vector_map<T,U>::iterator)&pairs_[pairs_.size()-1];
+ return pairs_.begin() + (pairs_.size()-1);
+ //~ return (typename vector_map<T,U>::iterator)&pairs_[pairs_.size()-1];
+
}
//-----------------------------------------------------------------------
Modified: sandbox/stm/branches/vbe/boost/stm/detail/vector_set.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/vector_set.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/vector_set.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -51,9 +51,9 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
- typename vector_set<T>::iterator find(T const &t)
+ iterator find(T const &t)
{
- for (typename vector_set<T>::iterator i = elements_.begin(); i != elements_.end(); ++i)
+ for (iterator i = elements_.begin(); i != elements_.end(); ++i)
{
if (t == i) return i;
}
@@ -63,9 +63,9 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
- typename vector_set<T>::iterator insert(first_t const &rhs)
+ iterator insert(first_t const &rhs)
{
- for (typename vector_set<T>::iterator i = elements_.begin(); i != elements_.end(); ++i)
+ for (iterator i = elements_.begin(); i != elements_.end(); ++i)
{
if (rhs == *i)
{
@@ -74,14 +74,14 @@
}
elements_.push_back(rhs);
- return (typename vector_set<T>::iterator)&elements_[elements_.size()-1];
+ return (iterator)&elements_[elements_.size()-1];
}
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
- void erase(vector_set<T>::first_t const &rhs)
+ void erase(first_t const &rhs)
{
- for (typename vector_set<T>::iterator i = elements_.begin(); i != elements_.end(); ++i)
+ for (iterator i = elements_.begin(); i != elements_.end(); ++i)
{
if (rhs == *i)
{
@@ -92,7 +92,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
- void push_back(vector_set<T>::first_t const &rhs)
+ void push_back(first_t const &rhs)
{
elements_.push_back(rhs);
}
Modified: sandbox/stm/branches/vbe/boost/stm/language_like.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/language_like.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/language_like.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -22,6 +22,7 @@
#include <iostream>
#include <boost/assert.hpp>
#include <exception>
+
//---------------------------------------------------------------------------
// helper function to implement macros
namespace boost { namespace stm { namespace detail {
@@ -557,15 +558,9 @@
catch (int ex) { \
std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
}\
- catch (int& ex) { \
- std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
- }\
catch (const char* ex) {\
std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
}\
- catch (const char*& ex) {\
- std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
- }\
catch (std::string& ex) {\
std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
}\
@@ -591,6 +586,14 @@
std::cout << "*** ERROR: " <<__FILE__ << "["<<__LINE__<<"] catch UNKNOWN " << std::endl;\
}\
+#define dd\
+ catch (const char*& ex) {\
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
+ }\
+ catch (int& ex) { \
+ std::cout << "*** ERROR: "<< __FILE__ << "["<<__LINE__<<"] catch "<<ex << std::endl;\
+ }\
+
///////////////////////////////////////////////////////////////////////////////
#endif // BOOST_STM_LANGUAGE_LIKE__HPP
Modified: sandbox/stm/branches/vbe/boost/stm/latm/datatypes.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/latm/datatypes.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/latm/datatypes.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -22,7 +22,9 @@
#include <boost/synchro/poly/lock.hpp>
#else
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
#endif
namespace boost { namespace stm { namespace latm {
Modified: sandbox/stm/branches/vbe/boost/stm/memory_managers/base_memory_manager.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/memory_managers/base_memory_manager.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/memory_managers/base_memory_manager.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -15,7 +15,9 @@
#define BOOST_STM_BASE_MEMORY_MANAGER__HPP
//-----------------------------------------------------------------------------
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
//-----------------------------------------------------------------------------
#include <list>
//-----------------------------------------------------------------------------
Modified: sandbox/stm/branches/vbe/boost/stm/memory_managers/memory_manager.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/memory_managers/memory_manager.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/memory_managers/memory_manager.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -16,7 +16,9 @@
//-----------------------------------------------------------------------------
//#include <stdarg.h>
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
//-----------------------------------------------------------------------------
#include <list>
#include <exception>
Modified: sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/auto_lock.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -15,7 +15,9 @@
#define BOOST_STM_SYNC_AUTO_LOCK_H
//---------------------------------------------------------------------------
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
#include <stdexcept>
//---------------------------------------------------------------------------
#include <string>
Modified: sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/mutex.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -54,6 +54,7 @@
mutable Poly<lockable_type, Base> dyn_lock_;
};
+#if !defined(BOOST_STM_USE_BOOST_MUTEX) || !defined(BOOST_STM_T_USE_BOOST_MUTEX)
template <typename Base, template <class, class> class Poly >
class exclusive_lock_adapter<pthread_mutex_t, Base, Poly>
{
@@ -79,7 +80,7 @@
mutable lockable_type st_lock_;
mutable Poly<lockable_type, Base> dyn_lock_;
};
-
+#endif
#if 0
#if BOOST_STM_LATM_GENERIC
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-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -16,7 +16,9 @@
//-----------------------------------------------------------------------------
#include <assert.h>
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
//-----------------------------------------------------------------------------
#include <iostream>
#include <list>
@@ -29,7 +31,11 @@
//-----------------------------------------------------------------------------
#include <boost/stm/trace.hpp>
+#ifdef BOOST_USES_STATIC_TSS
+#include <boost/synchro/static_tss.hpp>
+#else
#include <boost/synchro/tss.hpp>
+#endif
//-----------------------------------------------------------------------------
#include <boost/stm/detail/config.hpp>
//-----------------------------------------------------------------------------
@@ -244,7 +250,9 @@
#endif
}
inline ~tss_context() {
- pthread_mutex_destroy(&mutex_);
+ #ifndef BOOST_STM_USE_BOOST_MUTEX
+ pthread_mutex_destroy(&mutex_);
+ #endif
}
tx_context tx_;
@@ -893,7 +901,7 @@
#endif
//--------------------------------------------------------------------------
template <typename T>
- T* new_shared_memory(T*/*ptr*/)
+ T* new_shared_memory(T*)
{
BOOST_STM_TRANSACTION_INVARIANT;
throw_if_forced_to_abort_on_new();
@@ -903,7 +911,7 @@
//--------------------------------------------------------------------------
template <typename T>
- T* new_memory(T*/*ptr*/)
+ T* new_memory(T*)
{
BOOST_STM_TRANSACTION_INVARIANT;
throw_if_forced_to_abort_on_new();
@@ -2416,11 +2424,18 @@
////////////////////////////////////////
#endif
-
+#ifdef BOOST_USES_STATIC_TSS
+ struct xxx{};
+ //~ static synchro::static_thread_specific_ptr<transaction_tss_storage,xxx> transaction_tss_storage_;
+ typedef synchro::static_thread_specific_ptr<transaction_tss_storage,xxx> transaction_tss_storage_type;
+ inline static TransactionsStack& transactions() {return transaction_tss_storage_type::get()->transactions_;}
+ public:
+#else
static synchro::implicit_thread_specific_ptr<transaction_tss_storage> transaction_tss_storage_;
public:
//~ inline TransactionsStack& transactions() {return transaction_tss_storage_ref_.transactions_;}
inline static TransactionsStack& transactions() {return transaction_tss_storage_->transactions_;}
+#endif
// transaction specific data
//int hasMutex_; // bool - 1 bit
@@ -2484,8 +2499,11 @@
#endif
public:
+#ifdef BOOST_USES_STATIC_TSS
+ inline static transaction* current() {return transaction_tss_storage_type::get()->transactions_.top();}
+#else
inline static transaction* current() {return transaction_tss_storage_->transactions_.top();}
-
+#endif
};
inline transaction* current_transaction() {return transaction::current();}
Modified: sandbox/stm/branches/vbe/boost/stm/transaction_bookkeeping.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/transaction_bookkeeping.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/transaction_bookkeeping.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -18,7 +18,9 @@
#include <vector>
#include <map>
#include <cstddef>
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
#include <boost/stm/datatypes.hpp>
namespace boost { namespace stm {
Modified: sandbox/stm/branches/vbe/boost/stm/transaction_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/transaction_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/transaction_object.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -15,7 +15,9 @@
#define BOOST_STM_TRANSACTION_OBJECT__HPP
//-----------------------------------------------------------------------------
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
//-----------------------------------------------------------------------------
#include <list>
#include <new>
Modified: sandbox/stm/branches/vbe/boost/stm/tx/deep_transaction_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/deep_transaction_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/deep_transaction_object.hpp 2010-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -16,7 +16,9 @@
//-----------------------------------------------------------------------------
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
//-----------------------------------------------------------------------------
#include <list>
#include <new>
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-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -16,7 +16,8 @@
//-----------------------------------------------------------------------------
//#include <stdarg.h>
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
//-----------------------------------------------------------------------------
#include <list>
//-----------------------------------------------------------------------------
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-03-21 12:55:06 EDT (Sun, 21 Mar 2010)
@@ -16,7 +16,9 @@
//-----------------------------------------------------------------------------
//#include <stdarg.h>
-#include <pthread.h>
+//~ #include <pthread.h>
+#include <boost/thread.hpp>
+
//-----------------------------------------------------------------------------
#include <list>
//-----------------------------------------------------------------------------
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