|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59757 - in sandbox/stm/branches/vbe/boost/stm: . tx
From: vicente.botet_at_[hidden]
Date: 2010-02-18 21:31:30
Author: viboes
Date: 2010-02-18 21:31:29 EST (Thu, 18 Feb 2010)
New Revision: 59757
URL: http://svn.boost.org/trac/boost/changeset/59757
Log:
Boost.STM/vbe:
* Solve BOOST_STM_RETURN with variable of type mixin
* Put dummy class on detail namespace
* Check if the transaction is in flight in mixin::ref()/value()
Text files modified:
sandbox/stm/branches/vbe/boost/stm/language_like.hpp | 14 ++++++-----
sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 47 +++++++++++++++++++++------------------
sandbox/stm/branches/vbe/boost/stm/tx/mixin.hpp | 4 +-
3 files changed, 35 insertions(+), 30 deletions(-)
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-02-18 21:31:29 EST (Thu, 18 Feb 2010)
@@ -53,11 +53,13 @@
bool no_opt_false() {return false;}
-template <typename T>
-T commit_and_return(transaction&t, T expression) {
- t.commit(); return expression;
+template <typename T> T commit_and_return(transaction&t, T const& var) {
+ T tmp(var);
+ t.commit();
+ return tmp;
}
+
bool commit_expr(transaction&t) {
t.commit(); return true;
}
@@ -72,7 +74,7 @@
catch (...) {}
}
-struct dummy{};
+struct dummy_exception{};
}}}
@@ -238,7 +240,7 @@
// user code here
#define BOOST_STM_E_RETRY(TX) \
- } catch(boost::stm::detail::dummy &ex) { throw; } \
+ } catch(boost::stm::detail::dummy_exception &ex) { throw; } \
ctrl=boost::stm::detail::none; \
} \
} catch(...) { \
@@ -249,7 +251,7 @@
} BOOST_STM_RETRY
#define BOOST_STM_E_BEFORE_RETRY(TX) \
- } catch(boost::stm::detail::dummy &ex) { throw; } \
+ } catch(boost::stm::detail::dummy_exception &ex) { throw; } \
ctrl=boost::stm::detail::none; \
} \
} catch(...) { \
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-02-18 21:31:29 EST (Thu, 18 Feb 2010)
@@ -55,6 +55,10 @@
//-----------------------------------------------------------------------------
namespace boost { namespace stm {
+namespace detail {
+ template <int> struct dummy { dummy(int) {} };
+}
+
//-----------------------------------------------------------------------------
// boolean which is used to invoke "begin_transaction()" upon transaction
// object construction (so two lines of code aren't needed to make a
@@ -651,18 +655,17 @@
}
}
#ifdef BOOST_STM_USE_BOOST
- template <int> struct dummy { dummy(int) {} };
//--------------------------------------------------------------------------
template <typename T>
inline
typename boost::enable_if<is_base_of<base_transaction_object, T>, void>::type
- delete_ptr(T *in, dummy<0> = 0) {
+ delete_ptr(T *in, detail::dummy<0> = 0) {
delete_tx_ptr(in);
}
template <typename T>
inline
typename boost::disable_if<is_base_of<base_transaction_object, T>, void>::type
- delete_ptr(T *in, dummy<1> = 0) {
+ delete_ptr(T *in, detail::dummy<1> = 0) {
delete_non_tx_ptr(in);
}
#endif
@@ -705,13 +708,13 @@
template <typename T>
inline
typename boost::enable_if<is_base_of<base_transaction_object, T>, void>::type
- delete_array(T *in, std::size_t size, dummy<0> = 0) {
+ delete_array(T *in, std::size_t size, detail::dummy<0> = 0) {
delete_tx_ptr(in, size);
}
template <typename T>
inline
typename boost::disable_if<is_base_of<base_transaction_object, T>, void>::type
- delete_array(T *in, std::size_t size, dummy<1> = 0) {
+ delete_array(T *in, std::size_t size, detail::dummy<1> = 0) {
delete_non_tx_ptr(in, size);
}
#endif
@@ -759,13 +762,13 @@
template <typename T>
inline
typename enable_if<is_base_of<base_transaction_object, T>, T*>::type
- as_new(T *in, dummy<0> = 0) {
+ as_new(T *in, detail::dummy<0> = 0) {
return as_new_tx(in);
}
template <typename T>
inline
typename disable_if<is_base_of<base_transaction_object, T>, T*>::type
- as_new(T *in, dummy<1> = 0) {
+ as_new(T *in, detail::dummy<1> = 0) {
return as_new_non_tx(in);
}
#endif
@@ -792,13 +795,13 @@
template <typename T>
inline
typename enable_if<is_base_of<base_transaction_object, T>, T*>::type
- as_new_array(T *in, std::size_t size, dummy<0> = 0) {
+ as_new_array(T *in, std::size_t size, detail::dummy<0> = 0) {
return as_new_tx_array(in, size);
}
template <typename T>
inline
typename disable_if<is_base_of<base_transaction_object, T>, T*>::type
- as_new_array(T *in, std::size_t size, dummy<1> = 0) {
+ as_new_array(T *in, std::size_t size, detail::dummy<1> = 0) {
return as_new_non_tx_array(in, size);
}
#endif
@@ -1137,31 +1140,31 @@
//--------------------------------------------------------------------------
template <typename T>
typename boost::enable_if<fusion::traits::is_sequence<T>, bool>::type
- all_members_in_this_thread(T const & in, dummy<0> = 0) {
+ all_members_in_this_thread(T const & in, detail::dummy<0> = 0) {
// not yet implemented
return false;
}
template <typename T>
typename boost::disable_if<fusion::traits::is_sequence<T>, bool>::type
- all_members_in_this_thread(T const & in, dummy<1> = 0) {
+ all_members_in_this_thread(T const & in, detail::dummy<1> = 0) {
return true;
}
template <typename T>
typename boost::enable_if<is_base_of<base_transaction_object, T>, bool>::type
- all_in_this_thread(T const & in, dummy<0> = 0) {
+ all_in_this_thread(T const & in, detail::dummy<0> = 0) {
return (in.transaction_thread() != threadId_) && all_members_in_this_thread(in);
}
template <typename T>
typename boost::disable_if<is_base_of<base_transaction_object, T>, bool>::type
- all_in_this_thread(T const & in, dummy<1> = 0) {
+ all_in_this_thread(T const & in, detail::dummy<1> = 0) {
return all_members_in_this_thread(in);
}
template <typename T>
- bool all_in_this_thread(T const * const in, std::size_t size, dummy<0> = 0) {
+ bool all_in_this_thread(T const * const in, std::size_t size, detail::dummy<0> = 0) {
for (int i=size-1; i>=0; --i) {
if (!all_in_this_thread(in[i])) {
return false;
@@ -1174,13 +1177,13 @@
//--------------------------------------------------------------------------
template <typename T>
static typename boost::enable_if<is_base_of<base_transaction_object, T>, bool>::type
- valid_thread(T const &in, dummy<0> = 0) {
+ valid_thread(T const &in, detail::dummy<0> = 0) {
return in.transaction_thread() != invalid_thread_id();
}
template <typename T>
typename boost::disable_if<is_base_of<base_transaction_object, T>, bool>::type
- static valid_thread(T const &in, dummy<1> = 0) {
+ static valid_thread(T const &in, detail::dummy<1> = 0) {
// not yet implemented
return in.transaction_thread() != invalid_thread_id();
@@ -1189,13 +1192,13 @@
//--------------------------------------------------------------------------
template <typename T>
static typename boost::enable_if<is_base_of<base_transaction_object, T>, void>::type
- set_thread(T & in, thread_id_t thread_id, dummy<0> = 0) {
+ set_thread(T & in, thread_id_t thread_id, detail::dummy<0> = 0) {
in.transaction_thread() = thread_id;
}
template <typename T>
typename boost::disable_if<is_base_of<base_transaction_object, T>, void>::type
- static set_thread(T & in, thread_id_t thread_id, dummy<1> = 0) {
+ static set_thread(T & in, thread_id_t thread_id, detail::dummy<1> = 0) {
// not yet implemented
in.transaction_thread() = thread_id;
}
@@ -1461,26 +1464,26 @@
//--------------------------------------------------------------------------
template <typename T>
typename boost::enable_if<is_base_of<base_transaction_object, T>, void>::type
- writeList_insert(T & in, dummy<0> = 0) {
+ writeList_insert(T & in, detail::dummy<0> = 0) {
writeList().insert(tx_pair(&in, 0));
}
template <typename T>
typename boost::disable_if<is_base_of<base_transaction_object, T>, void>::type
- writeList_insert(T & in, dummy<1> = 0) {
+ writeList_insert(T & in, detail::dummy<1> = 0) {
// not yet implemented
writeList().insert(tx_pair(&in, 0));
}
//--------------------------------------------------------------------------
template <typename T>
typename boost::enable_if<is_base_of<base_transaction_object, T>, void>::type
- bloom_insert(T & in, dummy<0> = 0) {
+ bloom_insert(T & in, detail::dummy<0> = 0) {
bloom().insert((std::size_t)(&in));
}
template <typename T>
typename boost::disable_if<is_base_of<base_transaction_object, T>, void>::type
- bloom_insert(T & in, dummy<1> = 0) {
+ bloom_insert(T & in, detail::dummy<1> = 0) {
// not yet implemented
bloom().insert((std::size_t)(&in));
}
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-02-18 21:31:29 EST (Thu, 18 Feb 2010)
@@ -63,7 +63,7 @@
// accessors
T& ref() {
transaction* tx=current_transaction();
- if (tx!=0) {
+ if (tx!=0 && tx->in_flight()) {
if (tx->forced_to_abort()) {
tx->lock_and_abort();
throw aborted_transaction_exception("aborting transaction");
@@ -80,7 +80,7 @@
//-----------------------------------------------------------------------------
T value() const {
transaction* tx=current_transaction();
- if (tx!=0) {
+ if (tx!=0 && tx->in_flight()) {
if (tx->forced_to_abort()) {
tx->lock_and_abort();
throw aborted_transaction_exception("aborting transaction");
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