Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50463 - sandbox/interthreads/libs/interthreads/example
From: vicente.botet_at_[hidden]
Date: 2009-01-04 13:02:31


Author: viboes
Date: 2009-01-04 13:02:30 EST (Sun, 04 Jan 2009)
New Revision: 50463
URL: http://svn.boost.org/trac/boost/changeset/50463

Log:
interthreads version 0.2
Adding threader/joiner
Adding Asynchronous Executors fmk
Text files modified:
   sandbox/interthreads/libs/interthreads/example/async_ostream.hpp | 1 -
   sandbox/interthreads/libs/interthreads/example/basic_keep_alive.cpp | 24 ++++++++++++++++++++++--
   sandbox/interthreads/libs/interthreads/example/multiple_algorithms.cpp | 12 ++++++------
   3 files changed, 28 insertions(+), 9 deletions(-)

Modified: sandbox/interthreads/libs/interthreads/example/async_ostream.hpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/example/async_ostream.hpp (original)
+++ sandbox/interthreads/libs/interthreads/example/async_ostream.hpp 2009-01-04 13:02:30 EST (Sun, 04 Jan 2009)
@@ -19,7 +19,6 @@
 
 #include <iosfwd> // std::streamsize
 #include <iostream> // std::ostream
-#include <iostream> // std::cout
 
 
 namespace boost {

Modified: sandbox/interthreads/libs/interthreads/example/basic_keep_alive.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/example/basic_keep_alive.cpp (original)
+++ sandbox/interthreads/libs/interthreads/example/basic_keep_alive.cpp 2009-01-04 13:02:30 EST (Sun, 04 Jan 2009)
@@ -12,6 +12,7 @@
 
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/thread.hpp>
+
 boost::mutex out_global_mutex2;
 
 void sleep(int sec)
@@ -23,9 +24,11 @@
 }
 
 
+// #include <boost/interthreads/threader.hpp>
+// #include <boost/interthreads/joiner_tuple.hpp>
     #include <boost/interthreads/thread_decorator.hpp>
     #include <boost/interthreads/thread_keep_alive.hpp>
- #include "./async_ostream.cpp"
+// #include "./async_ostream.cpp"
     #include "./async_ostream.hpp"
     #include <boost/thread/thread.hpp>
     #include <iostream>
@@ -33,6 +36,10 @@
         
     namespace bith = boost::interthreads;
 
+ int my_thread1() {
+ sleep(2);
+ return 1;
+ }
     void my_thread() {
         bith::this_thread::enable_keep_alive enabler;
         for (int i=0; i<10; i++) {
@@ -40,7 +47,7 @@
 
             boost::thread::id id= boost::this_thread::get_id();
             std::stringstream sss;
-#define COUT_
+//#define COUT_
 #ifdef COUT_
             bith::cout_ << "TID=" << i << " " << id << std::endl;
             bith::cout_.flush();
@@ -55,6 +62,19 @@
     }
     
     int main() {
+ #if 0
+ bith::threader MyThreader;
+ {
+ bith::joiner<void> MyJoiner(MyThreader.fork(my_thread));
+ MyJoiner.join();
+ std::cout << "end" << std::endl;
+ }
+ {
+ bith::joiner<int> MyJoiner(MyThreader.fork(my_thread1));
+ int i = MyJoiner.get();
+ std::cout << "i=" << i << std::endl;
+ }
+ #endif
         boost::thread th1(bith::make_decorator(my_thread));
         boost::thread th2(bith::make_decorator(my_thread));
         boost::thread th3(bith::make_decorator(my_thread));

Modified: sandbox/interthreads/libs/interthreads/example/multiple_algorithms.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/example/multiple_algorithms.cpp (original)
+++ sandbox/interthreads/libs/interthreads/example/multiple_algorithms.cpp 2009-01-04 13:02:30 EST (Sun, 04 Jan 2009)
@@ -78,15 +78,15 @@
         boost::thread* th1 = tgo.create_thread(my_thread1);
         boost::thread* th2 = tgo.create_thread(my_thread2);
         boost::thread* th3 = tgo.create_thread(my_thread3);
- boost::thread* res_tgo= tgo.join_first();
- std::cout << "Algotithm " << res_tgo << " " << th2 << " finished the first with thread_group_once::join_first" << std::endl;
+ boost::thread* res_tgo= tgo.join_any();
+ std::cout << "Algotithm " << res_tgo << " " << th2 << " finished the first with thread_group_once::join_any" << std::endl;
         
        
- bith::thread_and_join_all(my_thread1, my_thread2, my_thread3);
- std::cout << "All finished thread_and_join_all" << std::endl;
+ bith::conc_join_all(my_thread1, my_thread2, my_thread3);
+ std::cout << "All finished conc_join_all" << std::endl;
 
- unsigned res = bith::thread_and_join_first_then_interrupt(my_thread1, my_thread2, my_thread3);
- std::cout << "Algotithm " << res+1 << " finished the first with thread_and_join_first_then_interrupt" << std::endl;
+ unsigned res = bith::conc_join_any(my_thread1, my_thread2, my_thread3);
+ std::cout << "Algotithm " << res+1 << " finished the first with conc_join_any" << std::endl;
 #endif
         
         return 0;


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