|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57573 - in sandbox/stm/branches/vbe: boost/stm/detail boost/stm/synch libs/stm/test
From: vicente.botet_at_[hidden]
Date: 2009-11-11 11:56:01
Author: viboes
Date: 2009-11-11 11:55:58 EST (Wed, 11 Nov 2009)
New Revision: 57573
URL: http://svn.boost.org/trac/boost/changeset/57573
Log:
TBoost.STM vbe: Use of BOOST_STM_SYNCHRONIZE
Text files modified:
sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 1 +
sandbox/stm/branches/vbe/boost/stm/synch/synchronized.hpp | 29 +++++++++++++++++++++--------
sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp | 23 +++++++++++------------
sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp | 8 ++++----
sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp | 11 +++++------
sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp | 12 ++++++++----
sandbox/stm/branches/vbe/libs/stm/test/txLinearLock.cpp | 28 +++++++++++++++-------------
sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp | 4 ++--
8 files changed, 67 insertions(+), 49 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 2009-11-11 11:55:58 EST (Wed, 11 Nov 2009)
@@ -155,6 +155,7 @@
//#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
#endif
///////////////////////////////////////////////////////////////////////////////
Modified: sandbox/stm/branches/vbe/boost/stm/synch/synchronized.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/synch/synchronized.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/synch/synchronized.hpp 2009-11-11 11:55:58 EST (Wed, 11 Nov 2009)
@@ -18,19 +18,19 @@
for (VAR_DECL;!__stop; __stop= true)
#define BOOST_STM_SYNCHRONIZE_TYPE(TYPE, VAR, LOCKABLE) \
- BOOST_STM_SYNCHRONIZE_EXT(boost::stm::unique_lock<TYPE> VAR(LOCKABLE))
-
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm::unique_lock<boost::stm::exclusive_lock_adapter<TYPE> > VAR(LOCKABLE))
#define BOOST_STM_ADOPT_SYNCHRONIZE_TYPE(TYPE, VAR, LOCKABLE) \
- BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(LOCKABLE, boost::synchro::adopt_lock))
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<boost::stm::exclusive_lock_adapter<TYPE> > VAR(LOCKABLE, boost::synchro::adopt_lock))
#define BOOST_STM_DEFER_SYNCHRONIZE_TYPE(TYPE, VAR, LOCKABLE) \
- BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(LOCKABLE, boost::synchro::defer_lock))
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<boost::stm::exclusive_lock_adapter<TYPE> > VAR(LOCKABLE, boost::synchro::defer_lock))
#define BOOST_STM_TRY_TO_SYNCHRONIZE_TYPE(TYPE, VAR, LOCKABLE) \
- BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(LOCKABLE, boost::synchro::try_to_lock))
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<boost::stm::exclusive_lock_adapter<TYPE> > VAR(LOCKABLE, boost::synchro::try_to_lock))
#define BOOST_STM_TRY_TO_SYNCHRONIZE_TYPE_UNTIL(TYPE, VAR, LOCKABLE, ABS_TIME) \
- BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(LOCKABLE, ABS_TIME))
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<boost::stm::exclusive_lock_adapter<TYPE> > VAR(LOCKABLE, ABS_TIME))
#define BOOST_STM_SYNCHRONIZE_TYPE_UNTIL(TYPE, VAR, LOCKABLE, ABS_TIME) \
- BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<TYPE> VAR(ABS_TIME, LOCKABLE))
+ BOOST_STM_SYNCHRONIZE_EXT(boost::stm:unique_lock<boost::stm::exclusive_lock_adapter<TYPE> > VAR(ABS_TIME, LOCKABLE))
+#if defined(BOOST_STM_T_USE_BOOST_MUTEX)
#define BOOST_STM_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
BOOST_STM_SYNCHRONIZE_TYPE(boost::mutex, VAR, LOCKABLE)
#define BOOST_STM_ADOPT_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
@@ -43,7 +43,20 @@
BOOST_STM_SYNCHRONIZE_TYPE_UNTIL(boost::mutex, VAR, LOCKABLE, ABS_TIME)
#define BOOST_STM_TRY_TO_SYNCHRONIZE_VAR_UNTIL(VAR, LOCKABLE, ABS_TIME) \
BOOST_STM_TRY_TO_SYNCHRONIZE_TYPE_UNTIL(boost::mutex, VAR, LOCKABLE, ABS_TIME)
-
+#else
+#define BOOST_STM_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
+ BOOST_STM_SYNCHRONIZE_TYPE(pthread_mutex_t, VAR, LOCKABLE)
+#define BOOST_STM_ADOPT_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
+ BOOST_STM_ADOPT_SYNCHRONIZE_TYPE(pthread_mutex_t, VAR, LOCKABLE)
+#define BOOST_STM_DEFER_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
+ BOOST_STM_DEFER_SYNCHRONIZE_TYPE(pthread_mutex_t, VAR, LOCKABLE)
+#define BOOST_STM_TRY_TO_SYNCHRONIZE_VAR(VAR, LOCKABLE) \
+ BOOST_STM_TRY_TO_SYNCHRONIZE_TYPE(pthread_mutex_t, VAR, LOCKABLE)
+#define BOOST_STM_SYNCHRONIZE_VAR_UNTIL(VAR, LOCKABLE, ABS_TIME) \
+ BOOST_STM_SYNCHRONIZE_TYPE_UNTIL(pthread_mutex_t, VAR, LOCKABLE, ABS_TIME)
+#define BOOST_STM_TRY_TO_SYNCHRONIZE_VAR_UNTIL(VAR, LOCKABLE, ABS_TIME) \
+ BOOST_STM_TRY_TO_SYNCHRONIZE_TYPE_UNTIL(pthread_mutex_t, VAR, LOCKABLE, ABS_TIME)
+#endif
#define BOOST_STM_SYNCHRONIZE(LOCKABLE) \
BOOST_STM_SYNCHRONIZE_VAR(_, LOCKABLE)
#define BOOST_STM_ADOPT_SYNCHRONIZE(LOCKABLE) \
Modified: sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx.cpp 2009-11-11 11:55:58 EST (Wed, 11 Nov 2009)
@@ -68,20 +68,20 @@
{
try
{
- {
- stm::lock_guard<mutex_type> lk(lock1);
- ++gInt.value();
- cout << "\t" << gInt.value() << endl;
+ BOOST_STM_SYNCHRONIZE(lock1) {
+ //stm::lock_guard<mutex_type> lk(lock1);
+ ++gInt.value();
+ cout << "\t" << gInt.value() << endl;
}
SLEEP(1000);
// do nothing on purpose, allowing other threads time to see
// intermediate state IF they can get lock1 (they shouldn't)
- {
- stm::lock_guard<mutex_type> lk(lock1);
- --gInt.value();
- cout << "\t" << gInt.value() << endl;
+ BOOST_STM_SYNCHRONIZE(lock1) {
+ //stm::lock_guard<mutex_type> lk(lock1);
+ --gInt.value();
+ cout << "\t" << gInt.value() << endl;
}
t.end();
@@ -119,10 +119,9 @@
for (int i = startingValue; i < 100*endingValue; ++i)
{
- {
- stm::lock_guard<mutex_type> lk(lock1);
- cout << gInt.value() << endl;
- }
+ BOOST_STM_SYNCHRONIZE(lock1)
+ //stm::lock_guard<mutex_type> lk(lock1);
+ cout << gInt.value() << endl;
SLEEP(10); // do nothing on purpose
}
Modified: sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/isolatedComposedIntLockInTx2.cpp 2009-11-11 11:55:58 EST (Wed, 11 Nov 2009)
@@ -70,8 +70,8 @@
t.lock_conflict(&lock1);
try
{
- {
- stm::lock_guard<mutex_type> lk(lock1);
+ BOOST_STM_SYNCHRONIZE(lock1) {
+ //stm::lock_guard<mutex_type> lk(lock1);
++gInt.value();
cout << "\t" << gInt.value() << endl;
}
@@ -80,8 +80,8 @@
// do nothing on purpose, allowing other threads time to see
// intermediate state IF they can get lock1 (they shouldn't)
- {
- stm::lock_guard<mutex_type> lk(lock1);
+ BOOST_STM_SYNCHRONIZE(lock1) {
+ //stm::lock_guard<mutex_type> lk(lock1);
--gInt.value();
cout << "\t" << gInt.value() << endl;
}
Modified: sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/isolatedIntLockInTx.cpp 2009-11-11 11:55:58 EST (Wed, 11 Nov 2009)
@@ -81,14 +81,13 @@
// global memory (gInt), its state must be updated to
// reflect all changes made previously inside the tx
//-------------------------------------------------------
- {
- stm::lock_guard<mutex_type> lk(lock1);
- cout << gInt.value() << endl;
-
- ++gInt.value();
+ BOOST_STM_SYNCHRONIZE(lock1) {
+ //stm::lock_guard<mutex_type> lk(lock1);
+ cout << gInt.value() << endl;
- if (oldVal + 2 != gInt.value()) cout << "invariant violated" << endl;
+ ++gInt.value();
+ if (oldVal + 2 != gInt.value()) cout << "invariant violated" << endl;
}
//-------------------------------------------------------
Modified: sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/litExample.cpp 2009-11-11 11:55:58 EST (Wed, 11 Nov 2009)
@@ -64,7 +64,8 @@
static void inc2()
{
- stm::lock_guard<mutex_type> lk(L2);
+ BOOST_STM_SYNCHRONIZE(L2)
+ //stm::lock_guard<mutex_type> lk(L2);
for (int i = 0; i < kMaxArrSize; ++i)
{
++arr2[i].value();
@@ -73,7 +74,8 @@
static void inc3()
{
- stm::lock_guard<mutex_type> lk(L3);
+ BOOST_STM_SYNCHRONIZE(L3)
+ //stm::lock_guard<mutex_type> lk(L3);
for (int i = 0; i < kMaxArrSize; ++i)
{
++arr3[i].value();
@@ -82,7 +84,8 @@
static void inc4()
{
- stm::lock_guard<mutex_type> lk(L4);
+ BOOST_STM_SYNCHRONIZE(L4)
+ //stm::lock_guard<mutex_type> lk(L4);
for (int i = 0; i < kMaxArrSize; ++i)
{
++arr4[i].value();
@@ -138,7 +141,8 @@
if (work3) return;
work3 = true;
- stm::lock_guard<mutex_type> lk(L8);
+ //stm::lock_guard<mutex_type> lk(L8);
+ BOOST_STM_SYNCHRONIZE(L8)
for (int i = 0; i < kMaxArrSize; ++i)
{
++arr8[i].value();
Modified: sandbox/stm/branches/vbe/libs/stm/test/txLinearLock.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/txLinearLock.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/txLinearLock.cpp 2009-11-11 11:55:58 EST (Wed, 11 Nov 2009)
@@ -51,16 +51,16 @@
try
{
- {
- stm::lock_guard<mutex_type> lk(lock2);
- --gInt2.value();
- cout << "\tgInt2: " << gInt2.value() << endl;
+ BOOST_STM_SYNCHRONIZE(lock2) {
+ //stm::lock_guard<mutex_type> lk(lock2);
+ --gInt2.value();
+ cout << "\tgInt2: " << gInt2.value() << endl;
}
SLEEP(1000);
- {
- stm::lock_guard<mutex_type> lk(lock2);
+ BOOST_STM_SYNCHRONIZE(lock2) {
+ //stm::lock_guard<mutex_type> lk(lock2);
++gInt1.value();
cout << "\tgInt1: " << gInt1.value() << endl;
}
@@ -102,13 +102,15 @@
{
SLEEP(1000);
- stm::lock_guard<mutex_type> lk(lock1);
- stm::lock_guard<mutex_type> lk2(lock2);
-
- --gInt1.value();
- ++gInt2.value();
- cout << "\t\tgInt1: " << gInt1.value() << endl;
- cout << "\t\tgInt2: " << gInt2.value() << endl;
+ BOOST_STM_SYNCHRONIZE(lock1) BOOST_STM_SYNCHRONIZE(lock2) {
+ //stm::lock_guard<mutex_type> lk(lock1);
+ //stm::lock_guard<mutex_type> lk2(lock2);
+
+ --gInt1.value();
+ ++gInt2.value();
+ cout << "\t\tgInt1: " << gInt1.value() << endl;
+ cout << "\t\tgInt2: " << gInt2.value() << endl;
+ }
}
Modified: sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/usingLockTx.cpp 2009-11-11 11:55:58 EST (Wed, 11 Nov 2009)
@@ -287,8 +287,8 @@
{
transaction::initialize_thread();
- stm::lock_guard<mutex_type> lk(L2);
-
+ BOOST_STM_SYNCHRONIZE(L2)
+ //stm::lock_guard<mutex_type> lk(L2);
SLEEP(10000);
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