Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57650 - sandbox/stm/branches/vbe/libs/stm/example/tx
From: vicente.botet_at_[hidden]
Date: 2009-11-14 11:24:55


Author: viboes
Date: 2009-11-14 11:24:54 EST (Sat, 14 Nov 2009)
New Revision: 57650
URL: http://svn.boost.org/trac/boost/changeset/57650

Log:
TBoost.STM vbe: Make list::remove on tx/list.cpp work

Text files modified:
   sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp | 35 ++++++++++++++---------------------
   1 files changed, 14 insertions(+), 21 deletions(-)

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 2009-11-14 11:24:54 EST (Sat, 14 Nov 2009)
@@ -94,8 +94,8 @@
     void insert(const T& val) {
         //cerr << __LINE__ << " * insert" << endl;
         BOOST_STM_ATOMIC(_) {
- list_node<T>* prev=head_;
- list_node<T> * curr=head_->next_.value();
+ list_node<T> const * prev = head_;
+ list_node<T> const * curr = prev->next_;
             while (curr!=0) {
                 if (curr->value_ == val) return;
                 else if (curr->value_ > val) break;
@@ -103,7 +103,7 @@
                 curr = curr->next_.value();
             }
             if (curr==0 || (curr->value_ > val)) {
- prev->next_=BOOST_STM_TX_NEW_PTR(_,list_node<T>(val, curr));
+ const_cast<list_node<T> *>(prev)->next_=BOOST_STM_TX_NEW_PTR(_,list_node<T>(val, const_cast<list_node<T> *>(curr)));
                 ++size_;
             }
         } BOOST_STM_END_ATOMIC
@@ -115,21 +115,14 @@
 
     // search function
     bool lookup(const T& val) const {
- //cerr << __LINE__ << " * lookup val=" << val << endl;
         BOOST_STM_ATOMIC(_) {
- list_node<T> const * curr=head_->next_.value();
+ list_node<T> const * curr=head_->next_;
             while (curr) {
- //cerr << __LINE__ << " * lookup curr->value_=" << curr->value_ << endl;
                 if (curr->value_ >= val) break;
                 curr = curr->next_.value();
             }
-
- //cerr << __LINE__ << " * lookup ret=" << ((curr) && (curr->value_ == val)) << endl;
             BOOST_STM_RETURN((curr) && (curr->value_ == val));
         } BOOST_STM_END_ATOMIC
- catch (...) {
- cerr << __LINE__ << " lookup" << endl;
- }
         return false;
     }
 
@@ -138,12 +131,12 @@
     {
         BOOST_STM_ATOMIC(_) {
             // find the node whose val matches the request
- list_node<T>* prev=head_;
- list_node<T>* curr=prev->next_.value();
+ list_node<T> const * prev=head_;
+ list_node<T> const * curr=prev->next_;
             while (curr) {
                 // if we find the node, disconnect it and end the search
                 if (curr->value_ == val) {
- prev->next_=curr->next_.value();
+ const_cast<list_node<T> *>(prev)->next_=curr->next_;
                     // delete curr...
                     BOOST_STM_TX_DELETE_PTR(_,curr);
                     --size_;
@@ -267,20 +260,20 @@
     //fails= fails || !insert1();
     thread th1(insert1_th);
     thread th2(insert2_th);
- //thread th3(insert2_th);
- //thread th4(insert3_th);
+ thread th3(insert2_th);
+ thread th4(insert3_th);
     
     th1.join();
     th2.join();
- //th3.join();
- //th4.join();
+ th3.join();
+ th4.join();
     fails= fails || !check_lookup(1);
     fails= fails || !check_lookup(2);
- fails= fails || !check_size(2);
+ fails= fails || !check_size(3);
     remove2();
     fails= fails || !check_lookup(1);
- //fails= fails || check_lookup(2);
- fails= fails || !check_size(1);
+ fails= fails || check_lookup(2);
+ fails= fails || !check_size(2);
     #if 0
     SLEEP(2);
     #endif


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