Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59784 - sandbox/stm/branches/vbe/libs/stm/example/tx
From: vicente.botet_at_[hidden]
Date: 2010-02-20 11:40:31


Author: viboes
Date: 2010-02-20 11:40:30 EST (Sat, 20 Feb 2010)
New Revision: 59784
URL: http://svn.boost.org/trac/boost/changeset/59784

Log:
Boost.STM/vbe:
* Adapt examples to new language like macros names
Text files modified:
   sandbox/stm/branches/vbe/libs/stm/example/tx/bank.cpp | 16 ++++----
   sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp | 36 ++++++++++----------
   sandbox/stm/branches/vbe/libs/stm/example/tx/list_sp.cpp | 28 ++++++++--------
   sandbox/stm/branches/vbe/libs/stm/example/tx/numeric.cpp | 70 ++++++++++++++++++++-------------------
   4 files changed, 76 insertions(+), 74 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-02-20 11:40:30 EST (Sat, 20 Feb 2010)
@@ -47,9 +47,9 @@
         return amount;
     }
     int Balance() const {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
             BOOST_STM_E_RETURN(_, balance_);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
         return 0;
     }
     int Nb() const {
@@ -161,12 +161,12 @@
         a->Deposit(10);
     } BOOST_STM_RETRY
 
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         int res = (a->Balance()==10?0:1);
         //BUG assertion "pthread_mutex_lock(&lockable)==0&&"synchro::lock<pthread_mutex_t>"" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 46
         //~ BOOST_STM_TX_DELETE_PTR(_, a.value());
         BOOST_STM_E_RETURN(_, res);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return 1;
 }
 
@@ -178,11 +178,11 @@
     thread th1(account_withdraw_thr);
 
     th1.join();
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         int res = (a->Balance()==-10?0:1);
         //~ BOOST_STM_TX_DELETE_PTR(_, a.value());
         BOOST_STM_E_RETURN(_, res);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return 1;
 }
 
@@ -200,11 +200,11 @@
     th2.join();
     th3.join();
     th4.join();
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         int res = (a->Balance()==0?0:1);
         //~ BOOST_STM_TX_DELETE_PTR(_, a.value());
         BOOST_STM_E_RETURN(_, res);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return 1;
 }
 

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-02-20 11:40:30 EST (Sat, 20 Feb 2010)
@@ -82,15 +82,15 @@
     ~list() { }
 
     std::size_t size() const {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
             BOOST_STM_E_RETURN(_,size_);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
         //~ BOOST_STM_TRANSACTION(_) {
             //~ BOOST_STM_RETURN(_, size_);
         //~ } BOOST_STM_RETRY
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
             BOOST_STM_E_RETURN(_,size_);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
         //~ BOOST_STM_TRANSACTION(_) {
             //~ BOOST_STM_RETURN(_, size_);
         //~ } BOOST_STM_RETRY
@@ -101,7 +101,7 @@
     // find the location to insert the node. if the value already exists, fail
     //--------------------------------------------------------------------------
     void insert(const T& val) {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
             list_node<T> * prev = head_;
             list_node<T> * curr = prev->next_;
             while (curr!=0) {
@@ -115,7 +115,7 @@
                 prev->next_=BOOST_STM_TX_NEW_PTR(_,list_node<T>(val, curr));
                 ++size_;
             }
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
         //~ catch (...) {
             //~ cerr << __LINE__ << " * insert" << endl;
         //~ }
@@ -123,14 +123,14 @@
 
     // search function
     bool lookup(const T& val) const {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
             list_node<T> const * curr=head_->next_;
             while (curr) {
                 if (curr->value_ >= val) break;
                 curr = curr->next_;
             }
             BOOST_STM_E_RETURN(_, ((curr) && (curr->value_ == val)));
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
         return false;
     }
 
@@ -176,17 +176,17 @@
     }
 }
 bool check_size(std::size_t val) {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
     //~ std::cout<< __FILE__<<"["<<__LINE__<<"]"<<std::endl;
         BOOST_STM_E_RETURN(_, (l.size()==val));
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 bool check_lookup(int val) {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         //cerr << " check_lookup " << l.lookup(val) << endl;
         BOOST_STM_E_RETURN(_, (l.lookup(val)));
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 
@@ -229,9 +229,9 @@
         int val = 10;
         n.next_=BOOST_STM_TX_NEW_PTR(_,test::list_node<int>(val, 0));
     } BOOST_STM_RETRY
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         BOOST_STM_E_RETURN(_, (n.next_->value_==10));
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 
@@ -239,9 +239,9 @@
     BOOST_STM_TRANSACTION(_) {
         n.next_->value_=12;
     } BOOST_STM_RETRY
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         BOOST_STM_E_RETURN(_, (n.next_->value_==12));
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 
@@ -252,9 +252,9 @@
         int val = 10;
         prev->next_=BOOST_STM_TX_NEW_PTR(_,test::list_node<int>(val, curr));
     } BOOST_STM_RETRY
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         BOOST_STM_E_RETURN(_, (n.next_->value_==10));
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 

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-02-20 11:40:30 EST (Sat, 20 Feb 2010)
@@ -66,9 +66,9 @@
     ~list() {}
 
     std::size_t size() const {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
             BOOST_STM_E_RETURN(_, size_);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
         return 0;
     }
 
@@ -76,7 +76,7 @@
     // find the location to insert the node. if the value already exists, fail
     //--------------------------------------------------------------------------
     void insert(const T& val) {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
             read_ptr<list_node<T> > prev(_, head_);
             read_ptr<list_node<T> > curr(_, prev->next_);
             while (curr!=0) {
@@ -89,19 +89,19 @@
                 make_write_ptr<static_poly>(prev)->next_=BOOST_STM_TX_NEW_PTR(_,list_node<T>(val, curr.get()));
                 ++(make_write_ptr<static_poly>(_, this)->size_);
             }
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     }
 
     // search function
     bool lookup(const T& val) const {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
             read_ptr<list_node<T> > curr(_, head_->next_);
             while (curr) {
                 if (curr->value_ >= val) break;
                 curr = curr->next_;
             }
             return (curr) && (curr->value_ == val);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
         return false;
     }
 
@@ -150,9 +150,9 @@
     }
 }
 bool check_size(std::size_t val) {
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         return (l.size()==val);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 bool check_lookup(int val) {
@@ -201,9 +201,9 @@
         int val = 10;
         n.next_=BOOST_STM_TX_NEW_PTR(_,test::list_node<int>(val, 0));
     } BOOST_STM_RETRY
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         return (n.next_->value_==10);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 
@@ -211,9 +211,9 @@
     BOOST_STM_TRANSACTION(_) {
         n.next_->value_=12;
     } BOOST_STM_RETRY
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         return (n.next_->value_==12);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 
@@ -225,9 +225,9 @@
         int val = 10;
         prev->next_=BOOST_STM_TX_NEW_PTR(_,test::list_node<int>(val, curr));
     } BOOST_STM_RETRY
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         return (n.next_->value_==10);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 

Modified: sandbox/stm/branches/vbe/libs/stm/example/tx/numeric.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/example/tx/numeric.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/example/tx/numeric.cpp 2010-02-20 11:40:30 EST (Sat, 20 Feb 2010)
@@ -88,14 +88,14 @@
 
 bool test_assign() {
     //thread_initializer thi;
- for(int i=0; i<2;++i)
- BOOST_STM_B_TRANSACTION_IN_LOOP(_) {
+ for(int i=0; i<2;++i) {
+ BOOST_STM_TRANSACTION_IN_LOOP(_) {
         counter=1;
         counter2=counter;
- continue;
+ BOOST_STM_CONTINUE(_);
         counter2=3;
- } BOOST_STM_RETRY_END(_)
-
+ } BOOST_STM_END_TRANSACTION_IN_LOOP(_)
+ }
     BOOST_STM_TRANSACTION(_) {
         //assert((counter==1) && (counter2==1) && (counter==counter2));
         BOOST_STM_TX_RETURN(_, (counter==1) && (counter2==1) && (counter==counter2)) ;
@@ -106,40 +106,40 @@
 bool test_less() {
     //thread_initializer thi;
     for(;;) {
- BOOST_STM_B_TRANSACTION_IN_LOOP(_) {
+ BOOST_STM_TRANSACTION_IN_LOOP(_) {
         counter=1;
         counter2=2;
- break;
+ BOOST_STM_BREAK(_);
         counter2=0;
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_END_TRANSACTION_IN_LOOP(_)
     }
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_)
         BOOST_STM_E_RETURN(_, (counter<counter2)) ;
- } BOOST_STM_RETRY_END(_)
+ BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 
 bool test_throw_e() {
- boost::stm::native_trans<int> x = 0;
-
     //thread_initializer thi;
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         counter=0; counter2=0;
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
 
     try{
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
             counter=1;
- //~ BOOST_STM_B_TRANSACTION(_) {
+ // BUG /bin/sh: line 4: 4428 Aborted (core dumped) "../../../bin.v2/libs/stm/test/numeric.test/gcc-3.4.4/debug/threading-multi/numeric.exe" > "../../../bin.v2/libs/stm/test/numeric.test/gcc-3.4.4/debug/threading-multi/numeric.output" 2>&1
+ //~ BOOST_STM_E_TRANSACTION(_) {
+ //~ counter=2;
                 throw 1;
- //~ } BOOST_STM_RETRY_END(_)
+ //~ } BOOST_STM_E_END_TRANSACTION(_)
             counter2=3;
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     } catch (...) {}
 
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         BOOST_STM_E_RETURN(_, (counter==0) && (counter2==0));
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
 
     return false;
 }
@@ -148,35 +148,37 @@
 bool test_assign_e() {
     //thread_initializer thi;
     for(int i=0; i<2;++i)
- BOOST_STM_B_TRANSACTION_IN_LOOP(_) {
+ {
+ BOOST_STM_E_TRANSACTION_IN_LOOP(_) {
         counter=1;
         counter2=counter;
         continue;
         counter2=3;
- } BOOST_STM_RETRY_END_IN_LOOP(_)
-
- BOOST_STM_B_TRANSACTION(_) {
+ } BOOST_STM_E_END_TRANSACTION_IN_LOOP(_)
+ }
+ BOOST_STM_E_TRANSACTION(_) {
         BOOST_STM_E_RETURN(_, (counter==1) && (counter2==1) && (counter==counter2)) ;
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
 
     return false;
 }
 
 bool test_less_e() {
     //thread_initializer thi;
- for(;;) {
- BOOST_STM_B_TRANSACTION_IN_LOOP(_)
+ for(;;)
+ {
+ BOOST_STM_E_TRANSACTION_IN_LOOP(_)
     {
         counter=1;
         counter2=2;
         break;
         counter2=0;
- } BOOST_STM_RETRY_END_IN_LOOP(_)
+ } BOOST_STM_E_END_TRANSACTION_IN_LOOP(_)
     }
- BOOST_STM_B_TRANSACTION(_)
+ BOOST_STM_E_TRANSACTION(_)
     {
         BOOST_STM_E_RETURN(_, counter<counter2);
- } BOOST_STM_RETRY_END(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 
@@ -198,10 +200,10 @@
     BOOST_STM_TRANSACTION(_) {
         counter2=c;
     } BOOST_STM_RETRY
- BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
         //assert(c==counter2);
- BOOST_STM_TX_RETURN(_, c==counter2) ;
- } BOOST_STM_RETRY_END(_)
+ BOOST_STM_E_RETURN(_, c==counter2) ;
+ } BOOST_STM_E_END_TRANSACTION(_)
     return false;
 }
 bool test_par() {
@@ -225,7 +227,7 @@
     fails += !test_equal();
     fails += !test_diff();
     fails += !test_assign();
- //~ // fails += !test_less();
+ fails += !test_less();
     fails += !test_assign_e();
     fails += !test_less_e();
     fails += !test_throw_e();


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