Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59772 - in sandbox/stm/branches/vbe/libs/stm: example/tx test
From: vicente.botet_at_[hidden]
Date: 2010-02-20 08:00:50


Author: viboes
Date: 2010-02-20 08:00:49 EST (Sat, 20 Feb 2010)
New Revision: 59772
URL: http://svn.boost.org/trac/boost/changeset/59772

Log:
Boost.STM/vbe:
* Adapt examples to new language like macros
Text files modified:
   sandbox/stm/branches/vbe/libs/stm/example/tx/bank.cpp | 24 ++++++++++++----------
   sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp | 41 ++++++++++++++++++++++++---------------
   sandbox/stm/branches/vbe/libs/stm/example/tx/list_sp.cpp | 5 ---
   sandbox/stm/branches/vbe/libs/stm/example/tx/numeric.cpp | 37 +++++++++++++++++++----------------
   sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 | 4 +-
   5 files changed, 61 insertions(+), 50 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 08:00:49 EST (Sat, 20 Feb 2010)
@@ -48,7 +48,7 @@
     }
     int Balance() const {
         BOOST_STM_B_TRANSACTION(_) {
- return balance_;
+ BOOST_STM_E_RETURN(_, balance_);
         } BOOST_STM_RETRY_END(_)
         return 0;
     }
@@ -161,12 +161,12 @@
         a->Deposit(10);
     } BOOST_STM_RETRY
 
- BOOST_STM_OUTER_TRANSACTION(_) {
+ BOOST_STM_B_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_TX_RETURN(_,res);
- } BOOST_STM_RETRY
+ BOOST_STM_E_RETURN(_, res);
+ } BOOST_STM_RETRY_END(_)
     return 1;
 }
 
@@ -178,11 +178,12 @@
     thread th1(account_withdraw_thr);
 
     th1.join();
- BOOST_STM_OUTER_TRANSACTION(_) {
+ BOOST_STM_B_TRANSACTION(_) {
         int res = (a->Balance()==-10?0:1);
         //~ BOOST_STM_TX_DELETE_PTR(_, a.value());
- BOOST_STM_TX_RETURN(_,res);
- } BOOST_STM_RETRY
+ BOOST_STM_E_RETURN(_, res);
+ } BOOST_STM_RETRY_END(_)
+ return 1;
 }
 
 int test_account_2() {
@@ -199,11 +200,12 @@
     th2.join();
     th3.join();
     th4.join();
- BOOST_STM_OUTER_TRANSACTION(_) {
+ BOOST_STM_B_TRANSACTION(_) {
         int res = (a->Balance()==0?0:1);
         //~ BOOST_STM_TX_DELETE_PTR(_, a.value());
- BOOST_STM_TX_RETURN(_,res);
- } BOOST_STM_RETRY
+ BOOST_STM_E_RETURN(_, res);
+ } BOOST_STM_RETRY_END(_)
+ return 1;
 }
 
 bool test_bank_1() {
@@ -280,7 +282,7 @@
     res+=test_account_0();
     res+=test_account_1();
     //BUG assertion "pthread_mutex_lock(&lockable)==0&&"synchro::lock<pthread_mutex_t>"" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 46
- //~ res+=test_account_2();
+ res+=test_account_2();
     res+=test_bank_1();
     res+=test_bank_2();
 

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 08:00:49 EST (Sat, 20 Feb 2010)
@@ -82,12 +82,18 @@
     ~list() { }
 
     std::size_t size() const {
- //~ BOOST_STM_B_TRANSACTION(_) {
- //~ return size_;
- //~ } BOOST_STM_RETRY_END(_)
- BOOST_STM_TRANSACTION(_) {
- BOOST_STM_RETURN(size_);
- } BOOST_STM_RETRY
+ BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_RETURN(_,size_);
+ } BOOST_STM_RETRY_END(_)
+ //~ BOOST_STM_TRANSACTION(_) {
+ //~ BOOST_STM_RETURN(_, size_);
+ //~ } BOOST_STM_RETRY
+ BOOST_STM_B_TRANSACTION(_) {
+ BOOST_STM_E_RETURN(_,size_);
+ } BOOST_STM_RETRY_END(_)
+ //~ BOOST_STM_TRANSACTION(_) {
+ //~ BOOST_STM_RETURN(_, size_);
+ //~ } BOOST_STM_RETRY
         return 0;
     }
 
@@ -99,7 +105,8 @@
             list_node<T> * prev = head_;
             list_node<T> * curr = prev->next_;
             while (curr!=0) {
- 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_;
@@ -122,7 +129,7 @@
                 if (curr->value_ >= val) break;
                 curr = curr->next_;
             }
- return ((curr) && (curr->value_ == val));
+ BOOST_STM_E_RETURN(_, ((curr) && (curr->value_ == val)));
         } BOOST_STM_RETRY_END(_)
         return false;
     }
@@ -170,15 +177,15 @@
 }
 bool check_size(std::size_t val) {
     BOOST_STM_B_TRANSACTION(_) {
- std::cout<< __FILE__<<"["<<__LINE__<<"]"<<std::endl;
- return (l.size()==val);
+ //~ std::cout<< __FILE__<<"["<<__LINE__<<"]"<<std::endl;
+ BOOST_STM_E_RETURN(_, (l.size()==val));
     } BOOST_STM_RETRY_END(_)
     return false;
 }
 bool check_lookup(int val) {
     BOOST_STM_B_TRANSACTION(_) {
         //cerr << " check_lookup " << l.lookup(val) << endl;
- return (l.lookup(val));
+ BOOST_STM_E_RETURN(_, (l.lookup(val)));
     } BOOST_STM_RETRY_END(_)
     return false;
 }
@@ -223,7 +230,7 @@
         n.next_=BOOST_STM_TX_NEW_PTR(_,test::list_node<int>(val, 0));
     } BOOST_STM_RETRY
     BOOST_STM_B_TRANSACTION(_) {
- return (n.next_->value_==10);
+ BOOST_STM_E_RETURN(_, (n.next_->value_==10));
     } BOOST_STM_RETRY_END(_)
     return false;
 }
@@ -233,13 +240,12 @@
         n.next_->value_=12;
     } BOOST_STM_RETRY
     BOOST_STM_B_TRANSACTION(_) {
- return (n.next_->value_==12);
+ BOOST_STM_E_RETURN(_, (n.next_->value_==12));
     } BOOST_STM_RETRY_END(_)
     return false;
 }
 
 bool n3() {
- //cerr << __LINE__ << " * n3" << endl;
     BOOST_STM_TRANSACTION(_) {
         test::list_node<int>* prev =&n;
         test::list_node<int>* curr =prev->next_;
@@ -247,19 +253,20 @@
         prev->next_=BOOST_STM_TX_NEW_PTR(_,test::list_node<int>(val, curr));
     } BOOST_STM_RETRY
     BOOST_STM_B_TRANSACTION(_) {
- return (n.next_->value_==10);
+ BOOST_STM_E_RETURN(_, (n.next_->value_==10));
     } BOOST_STM_RETRY_END(_)
     return false;
 }
 
 int test_all() {
+
     //create();
     bool fails=false;
     fails= fails || !n1();
     fails= fails || !n2();
     fails= fails || !n3();
     fails= fails || !check_size(0);
- //fails= fails || !insert1();
+ //~ fails= fails || !insert1();
     thread th1(insert1_th);
     thread th2(insert2_th);
     thread th3(insert2_th);
@@ -271,10 +278,12 @@
     th4.join();
     fails= fails || !check_lookup(1);
     fails= fails || !check_lookup(2);
+ fails= fails || !check_lookup(3);
     fails= fails || !check_size(3);
     remove2();
     fails= fails || !check_lookup(1);
     fails= fails || check_lookup(2);
+ fails= fails || !check_lookup(3);
     fails= fails || !check_size(2);
     return fails;
 }

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 08:00:49 EST (Sat, 20 Feb 2010)
@@ -67,7 +67,7 @@
 
     std::size_t size() const {
         BOOST_STM_B_TRANSACTION(_) {
- return size_;
+ BOOST_STM_E_RETURN(_, size_);
         } BOOST_STM_RETRY_END(_)
         return 0;
     }
@@ -90,9 +90,6 @@
                 ++(make_write_ptr<static_poly>(_, this)->size_);
             }
         } BOOST_STM_RETRY_END(_)
- //~ catch (...) {
- //~ cout << __LINE__ << " * insert" << endl;
- //~ }
     }
 
     // search function

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 08:00:49 EST (Sat, 20 Feb 2010)
@@ -114,7 +114,7 @@
     } BOOST_STM_RETRY_END(_)
     }
     BOOST_STM_B_TRANSACTION(_) {
- return (counter<counter2) ;
+ BOOST_STM_E_RETURN(_, (counter<counter2)) ;
     } BOOST_STM_RETRY_END(_)
     return false;
 }
@@ -128,17 +128,17 @@
     } BOOST_STM_RETRY_END(_)
 
     try{
- for(int i=0; i<2;++i) {
- BOOST_STM_B_TRANSACTION_IN_LOOP(_) {
+ BOOST_STM_B_TRANSACTION(_) {
             counter=1;
- throw 1;
+ //~ BOOST_STM_B_TRANSACTION(_) {
+ throw 1;
+ //~ } BOOST_STM_RETRY_END(_)
             counter2=3;
- } BOOST_STM_RETRY_END_IN_LOOP(_)
- }
+ } BOOST_STM_RETRY_END(_)
     } catch (...) {}
 
     BOOST_STM_B_TRANSACTION(_) {
- return (counter==0) && (counter2==0);
+ BOOST_STM_E_RETURN(_, (counter==0) && (counter2==0));
     } BOOST_STM_RETRY_END(_)
 
     return false;
@@ -156,7 +156,7 @@
     } BOOST_STM_RETRY_END_IN_LOOP(_)
 
     BOOST_STM_B_TRANSACTION(_) {
- return (counter==1) && (counter2==1) && (counter==counter2) ;
+ BOOST_STM_E_RETURN(_, (counter==1) && (counter2==1) && (counter==counter2)) ;
     } BOOST_STM_RETRY_END(_)
 
     return false;
@@ -175,7 +175,7 @@
     }
     BOOST_STM_B_TRANSACTION(_)
     {
- return counter<counter2;
+ BOOST_STM_E_RETURN(_, counter<counter2);
     } BOOST_STM_RETRY_END(_)
     return false;
 }
@@ -198,15 +198,13 @@
     BOOST_STM_TRANSACTION(_) {
         counter2=c;
     } BOOST_STM_RETRY
- BOOST_STM_TRANSACTION(_) {
+ BOOST_STM_B_TRANSACTION(_) {
         //assert(c==counter2);
- BOOST_STM_TX_RETURN(_, (c==counter2)) ;
- } BOOST_STM_RETRY
+ BOOST_STM_TX_RETURN(_, c==counter2) ;
+ } BOOST_STM_RETRY_END(_)
     return false;
 }
-
-int test_all() {
-
+bool test_par() {
     thread th1(inc);
     thread th2(decr);
     thread th3(inc1);
@@ -217,12 +215,17 @@
     th3.join();
     th4.join();
 
+ return check(2);
+}
+
+int test_all() {
     int fails=0;
- fails += !check(2);
+
+ fails += !test_par();
     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();

Modified: sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 2010-02-20 08:00:49 EST (Sat, 20 Feb 2010)
@@ -189,14 +189,14 @@
     alias embedded
         :
             [ run-fail ../example/embed.cpp ]
- [ run ../example/multiple_inheritance.cpp ]
     ;
 
     alias examples_tx
- :
+ : embedded
             [ compile-fail ../example/deep_singleton.cpp ]
             [ run ../example/singleton.cpp ]
             [ run ../example/dyn_poly.cpp ]
+ [ run ../example/multiple_inheritance.cpp ]
 
             [ run ../example/tx/bank.cpp : : : : tx_bank ]
             [ run ../example/tx/numeric.cpp ]


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