$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r60561 - sandbox/stm/branches/vbe/libs/stm/example/tx
From: vicente.botet_at_[hidden]
Date: 2010-03-13 18:13:01
Author: viboes
Date: 2010-03-13 18:13:00 EST (Sat, 13 Mar 2010)
New Revision: 60561
URL: http://svn.boost.org/trac/boost/changeset/60561
Log:
Boost.STM/vbe: 
* Warning removal
Text files modified: 
   sandbox/stm/branches/vbe/libs/stm/example/tx/bank.cpp    |     6 ++--                                    
   sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp    |    46 ++++++++++++++++++++++++++++----------- 
   sandbox/stm/branches/vbe/libs/stm/example/tx/list_sp.cpp |    18 +++++++-------                          
   3 files changed, 45 insertions(+), 25 deletions(-)
Modified: sandbox/stm/branches/vbe/libs/stm/example/tx/bank.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/example/tx/bank.cpp	(original)
+++ sandbox/stm/branches/vbe/libs/stm/example/tx/bank.cpp	2010-03-13 18:13:00 EST (Sat, 13 Mar 2010)
@@ -102,13 +102,13 @@
         for(int i=10; i>0;--i)
         {
             try {
-                BOOST_STM_OUTER_TRANSACTION(_) {
+                BOOST_STM_E_TRANSACTION {
                     int amount=random() % 1000;
                     int acc1=random() % bank_->accounts.size();
                     int acc2=random() % bank_->accounts.size();
                     bank_->accounts[acc1]->Withdraw(amount);
                     bank_->accounts[acc2]->Deposit(amount+1);
-                } BOOST_STM_RETRY
+                } BOOST_STM_E_END_TRANSACTION;
             }
             CATCH_AND_PRINT_ALL
         }
@@ -290,7 +290,7 @@
 }
 int main() {
     try {
-    std::terminate_handler x = std::set_terminate(term_hd);
+    std::set_terminate(term_hd);
     transaction::enable_dynamic_priority_assignment();
     transaction::do_deferred_updating();
     transaction::initialize();
Modified: sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp	(original)
+++ sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp	2010-03-13 18:13:00 EST (Sat, 13 Mar 2010)
@@ -120,14 +120,16 @@
 
     void insert(const T& val) {
         BOOST_STM_E_TRANSACTION {
+            {boost::lock_guard<boost::mutex> lk(log_mutex);
+            std::cout << &BOOST_STM_CURRENT << " " << BOOST_STM_CURRENT.parent() << " " << boost::this_thread::get_id() << " $$$$$INFO insert " << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+            }
             list_node<T> * prev = head_;
             list_node<T> * curr = prev->next_;
             while (curr!=0) {
-                if (curr->value_ == val) {
-        std::cout << __FILE__ << "["<<__LINE__<<"] return" << std::endl;\
-                    BOOST_STM_E_RETURN_NOTHING;
-                }
-                //~ if (curr->value_ == val) return;
+                //~ if (curr->value_ == val) {
+                    //~ BOOST_STM_E_RETURN_NOTHING;
+                //~ }
+                if (curr->value_ == val) return;
                 else if (curr->value_ > val) break;
                 prev = curr;
                 curr = curr->next_;
@@ -155,7 +157,10 @@
     // remove a node if its value == val
     void remove(const T& val)
     {
-        BOOST_STM_TRANSACTION(_) {
+        BOOST_STM_E_TRANSACTION {
+            {boost::lock_guard<boost::mutex> lk(log_mutex);
+            std::cout << &BOOST_STM_CURRENT << " " << BOOST_STM_CURRENT.parent() << " " << boost::this_thread::get_id() << " $$$$$INFO remove " << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+            }
             // find the node whose val matches the request
             list_node<T> * prev=head_;
             list_node<T> * curr=prev->next_;
@@ -164,7 +169,7 @@
                 if (curr->value_ == val) {
                     prev->next_=curr->next_;
                     // delete curr...
-                    BOOST_STM_TX_DELETE_PTR(_,curr);
+                    BOOST_STM_E_DELETE_PTR(curr);
                     --size_;
                     break;
                 } else if (curr->value_ > val) {
@@ -174,7 +179,7 @@
                 prev = curr;
                 curr = prev->next_;
             }
-        }  BOOST_STM_RETRY
+        }  BOOST_STM_E_END_TRANSACTION;
     }
 
 };
@@ -218,6 +223,10 @@
     thread_initializer thi;
     try {
         BOOST_STM_E_TRANSACTION {
+            {boost::lock_guard<boost::mutex> lk(log_mutex);
+            std::cout << &BOOST_STM_CURRENT << " " << BOOST_STM_CURRENT.parent() << " " << boost::this_thread::get_id() << " $$$$$INFO insert1_th " << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+            }
+
             l.insert(1);
         }  BOOST_STM_E_END_TRANSACTION;
     } 
@@ -228,6 +237,9 @@
     try {
     //~ BOOST_STM_OUTER_TRANSACTION(_) {
         BOOST_STM_E_TRANSACTION {
+            {boost::lock_guard<boost::mutex> lk(log_mutex);
+            std::cout << &BOOST_STM_CURRENT << " " << BOOST_STM_CURRENT.parent() << " " << boost::this_thread::get_id() << " $$$$$INFO insert2_th " << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+            }
             l.insert(2);
         } BOOST_STM_E_END_TRANSACTION;
     //~ } BOOST_STM_RETRY
@@ -237,18 +249,26 @@
 void insert3_th() {
     thread_initializer thi;
     try {
-    BOOST_STM_OUTER_TRANSACTION(_) {
+    //~ BOOST_STM_OUTER_TRANSACTION(_) {
+    BOOST_STM_E_TRANSACTION {
+            {boost::lock_guard<boost::mutex> lk(log_mutex);
+            std::cout << &BOOST_STM_CURRENT << " " << BOOST_STM_CURRENT.parent() << " " << boost::this_thread::get_id() << " $$$$$INFO insert3_th " << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+            }
         l.insert(3);
-    } BOOST_STM_RETRY
+    } BOOST_STM_E_END_TRANSACTION;
+    //~ } BOOST_STM_RETRY
     } 
     CATCH_AND_PRINT_ALL
 }
 
 bool remove(int val) {
     //thread_initializer thi;
-    BOOST_STM_TRANSACTION(_) {
+    BOOST_STM_E_TRANSACTION {
+            {boost::lock_guard<boost::mutex> lk(log_mutex);
+            std::cout << &BOOST_STM_CURRENT << " " << BOOST_STM_CURRENT.parent() << " " << boost::this_thread::get_id() << " $$$$$INFO remove " << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+            }
         l.remove(val);
-    } BOOST_STM_RETRY
+    } BOOST_STM_E_END_TRANSACTION;
     return true;
 }
 
@@ -335,7 +355,7 @@
 }
 int main() {
     try {
-    std::terminate_handler x = std::set_terminate(term_hd);
+    std::set_terminate(term_hd);
     transaction::enable_dynamic_priority_assignment();
     transaction::do_deferred_updating();
     transaction::initialize();
Modified: sandbox/stm/branches/vbe/libs/stm/example/tx/list_sp.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/example/tx/list_sp.cpp	(original)
+++ sandbox/stm/branches/vbe/libs/stm/example/tx/list_sp.cpp	2010-03-13 18:13:00 EST (Sat, 13 Mar 2010)
@@ -111,18 +111,18 @@
     // remove a node if its value == val
     void remove(const T& val)
     {
-        BOOST_STM_TRANSACTION(_) {
+        BOOST_STM_E_TRANSACTION {
             // find the node whose val matches the request
-            read_ptr<list_node<T> > prev(_, head_);
-            read_ptr<list_node<T> > curr(_, prev->next_);
+            read_ptr<list_node<T> > prev(BOOST_STM_CURRENT, head_);
+            read_ptr<list_node<T> > curr(BOOST_STM_CURRENT, prev->next_);
             while (curr) {
                 // if we find the node, disconnect it and end the search
                 if (curr->value_ == val) {
                     make_write_ptr<static_poly>(prev)->next_=curr->next_;
                     // delete curr...
-                    BOOST_STM_TX_DELETE_PTR(_,curr);
+                    BOOST_STM_E_DELETE_PTR(curr);
                     //--size_;
-                    --(make_write_ptr<static_poly>(_, this)->size_);
+                    --(make_write_ptr<static_poly>(BOOST_STM_CURRENT, this)->size_);
                     //write_ptr<list<T> > that(_, this);
                     //++(that->size_);
                     break;
@@ -133,7 +133,7 @@
                 prev = curr;
                 curr = prev->next_;
             }
-        }  BOOST_STM_RETRY
+        }  BOOST_STM_E_END_TRANSACTION;
     }
 
 };
@@ -194,9 +194,9 @@
 
 void remove2() {
     //thread_initializer thi;
-    BOOST_STM_TRANSACTION(_) {
+    BOOST_STM_E_TRANSACTION {
         l.remove(2);
-    } BOOST_STM_RETRY
+    } BOOST_STM_E_END_TRANSACTION;
 }
 
 void insert3_th() {
@@ -279,7 +279,7 @@
 }
 int main() {
     try {
-    std::terminate_handler x = std::set_terminate(term_hd);
+    std::set_terminate(term_hd);
     transaction::enable_dynamic_priority_assignment();
     transaction::do_deferred_updating();
     transaction::initialize();