$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r50585 - sandbox/interthreads/libs/interthreads/test
From: vicente.botet_at_[hidden]
Date: 2009-01-14 12:36:47
Author: viboes
Date: 2009-01-14 12:36:46 EST (Wed, 14 Jan 2009)
New Revision: 50585
URL: http://svn.boost.org/trac/boost/changeset/50585
Log:
interthreads version 0.2
Adding threader/joiner
Adding Asynchronous Executors fmk
Added:
   sandbox/interthreads/libs/interthreads/test/test_ae.hpp   (contents, props changed)
   sandbox/interthreads/libs/interthreads/test/test_thread_pool.cpp   (contents, props changed)
Text files modified: 
   sandbox/interthreads/libs/interthreads/test/Jamfile.v2                 |     6                                         
   sandbox/interthreads/libs/interthreads/test/test_basic_threader.cpp    |    87 +++++++----                             
   sandbox/interthreads/libs/interthreads/test/test_launcher.cpp          |   128 +++++++++++++----                       
   sandbox/interthreads/libs/interthreads/test/test_thread_decorator.cpp  |     2                                         
   sandbox/interthreads/libs/interthreads/test/test_thread_shared_ptr.cpp |     2                                         
   sandbox/interthreads/libs/interthreads/test/test_threader.cpp          |   296 ++++++++++++++++++--------------------- 
   6 files changed, 294 insertions(+), 227 deletions(-)
Modified: sandbox/interthreads/libs/interthreads/test/Jamfile.v2
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/Jamfile.v2	(original)
+++ sandbox/interthreads/libs/interthreads/test/Jamfile.v2	2009-01-14 12:36:46 EST (Wed, 14 Jan 2009)
@@ -1,6 +1,6 @@
 #  (C) Copyright William E. Kempf 2001. 
 #  (C) Copyright 2007 Anthony Williams. 
-#  (C) Copyright 2007 Vicente Botet Escriba. 
+#  (C) Copyright 2008-2009 Vicente Botet Escriba. 
 #  Distributed under the Boost Software License, Version 1.0. (See accompanying 
 #  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 #
@@ -29,7 +29,7 @@
       <target-os>cygwin
       <threadapi>pthread
       <variant>debug
-      <define>BOOST_THREAD_HAS_THREAD_ATTR
+#      <define>BOOST_THREAD_HAS_THREAD_ATTR
 
     ;
 
@@ -46,9 +46,11 @@
 {
     test-suite "tests"
         : 
+          [ interthreads-run move_test.cpp ]
           [ interthreads-run test_basic_threader.cpp ]
           [ interthreads-run test_launcher.cpp ]
           [ interthreads-run test_threader.cpp ]
+          [ interthreads-run test_thread_pool.cpp ]
           [ interthreads-run test_thread_decorator.cpp ]
           [ interthreads-run test_thread_shared_ptr.cpp ]
     ;
Added: sandbox/interthreads/libs/interthreads/test/test_ae.hpp
==============================================================================
--- (empty file)
+++ sandbox/interthreads/libs/interthreads/test/test_ae.hpp	2009-01-14 12:36:46 EST (Wed, 14 Jan 2009)
@@ -0,0 +1,214 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-20009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/sync for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_INTERTHREADS_TEST_AE__HPP
+#define BOOST_INTERTHREADS_TEST_AE__HPP
+
+#include <boost/interthreads/algorithm.hpp>
+#include <libs/interthreads/test/data_types.hpp>
+#include "boost/thread/mutex.hpp"
+#include "boost/thread/locks.hpp"
+#include "boost/thread/thread.hpp"
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/test/unit_test.hpp>
+#include <iostream>
+
+using namespace boost::unit_test;
+namespace bith = boost::interthreads;
+namespace bfus = boost::fusion;
+
+int test_value;
+int test_value2;
+int simple_thread() {
+    test_value=999;
+    sleep(2);
+    return test_value;
+}
+
+int simple_thread2() {
+    test_value2=111;
+    sleep(5);
+    return test_value2;
+}
+
+int simple_thread_1(unsigned i) {
+    test_value=i;
+    sleep(5);
+    return test_value;
+}
+
+bool interruption_point_thread(boost::mutex* m,bool* failed)
+{
+    boost::mutex::scoped_lock lk(*m);
+    boost::this_thread::interruption_point();
+    *failed=true;
+    return failed;
+}
+
+namespace aetst {
+
+template <typename AE>
+void do_test_member_fork(AE& ae) {
+    test_value=0;
+	BOOST_AUTO(act, ae.fork(simple_thread));
+    BOOST_CHECK_EQUAL(act.is_ready(), false);
+    BOOST_CHECK_EQUAL(act.has_value(), false);
+    BOOST_CHECK_EQUAL(act.has_exception(), false);
+    int res_value = act.get();
+    BOOST_CHECK_EQUAL(test_value, 999);
+    BOOST_CHECK_EQUAL(res_value, 999);
+    BOOST_CHECK_EQUAL(act.is_ready(), true);
+    BOOST_CHECK_EQUAL(act.has_value(), true);
+    BOOST_CHECK_EQUAL(act.has_exception(), false);
+}    
+template <typename AE>
+void do_test_member_fork_move(AE& ae) {
+    test_value=0;
+	typename AE::template handle<int>::type act = ae.fork(simple_thread);
+    BOOST_CHECK_EQUAL(act.is_ready(), false);
+    BOOST_CHECK_EQUAL(act.has_value(), false);
+    BOOST_CHECK_EQUAL(act.has_exception(), false);
+    int res_value = act.get();
+    BOOST_CHECK_EQUAL(test_value, 999);
+    BOOST_CHECK_EQUAL(res_value, 999);
+    BOOST_CHECK_EQUAL(act.is_ready(), true);
+    BOOST_CHECK_EQUAL(act.has_value(), true);
+    BOOST_CHECK_EQUAL(act.has_exception(), false);
+}    
+
+template <typename AE>
+void do_test_member_fork_bind(AE& ae) {
+    test_value=0;
+	BOOST_AUTO(act, ae.fork(boost::bind(simple_thread_1, 2)));
+    int res_value = act.get();
+    BOOST_CHECK_EQUAL(test_value, 2);
+    BOOST_CHECK_EQUAL(res_value, 2);
+}    
+
+template <typename AE>
+void do_test_fork(AE& ae) {
+    test_value=0;
+	BOOST_AUTO(act, bith::fork(ae, simple_thread));
+    int res_value = act.get();
+    BOOST_CHECK_EQUAL(test_value, 999);
+    BOOST_CHECK_EQUAL(res_value, 999);
+}    
+
+template <typename AE>
+void do_test_fork_1(AE& ae) {
+    test_value=0;
+	BOOST_AUTO(act, bith::fork(ae, simple_thread_1, 2));
+    int res_value = act.get();
+    BOOST_CHECK_EQUAL(test_value, 2);
+    BOOST_CHECK_EQUAL(res_value, 2);
+}    
+
+template <typename AE>
+void do_test_creation_through_functor(AE& ae)
+{
+    copyable_functor f;
+    BOOST_AUTO(act,bith::fork(ae, f));
+    int res = act.get();
+    BOOST_CHECK_EQUAL(res, 999);
+}
+
+template <typename AE>
+void do_test_creation_through_reference_wrapper(AE& ae)
+{
+    non_copyable_functor f;
+	BOOST_AUTO(act,bith::fork(ae, boost::bind(boost::ref(f))));
+    
+    unsigned res = act.get();
+    BOOST_CHECK_EQUAL(res, 999u);
+    BOOST_CHECK_EQUAL(f.value, 999u);
+}
+
+template <typename AE>
+void do_test_wait_all(AE& ae) {
+    BOOST_AUTO(tple,bith::fork_all(ae, simple_thread, simple_thread));
+    bith::wait_all(tple);
+}
+
+template <typename AE>
+void do_test_wait_for_any(AE& ae) {
+    BOOST_AUTO(res, bith::wait_for_any(ae, simple_thread, simple_thread2));
+    BOOST_CHECK_EQUAL(res.first, 0u);
+    BOOST_CHECK_EQUAL(res.second, 999);  
+    res = bith::wait_for_any(ae, simple_thread2, simple_thread);
+    BOOST_CHECK_EQUAL(res.first, 1u);
+    BOOST_CHECK_EQUAL(res.second, 999);  
+}
+
+template <typename AE>
+void do_test_set_all(AE& ae) {
+    BOOST_AUTO(tple,bith::fork_all(ae, simple_thread, simple_thread2));
+    bfus::tuple<int,int> res;
+    bith::set_all(tple,res);
+    BOOST_CHECK_EQUAL(bfus::at_c<0>(res), 999);
+    BOOST_CHECK_EQUAL(bfus::at_c<1>(res), 111);
+    
+    bfus::for_each(res, print_xml());
+    
+}
+
+template <typename AE>
+void do_test_wait_for_all(AE& ae) {
+    BOOST_AUTO(res, bith::wait_for_all(ae, simple_thread, simple_thread2));
+    bfus::for_each(res, print_xml());
+    BOOST_CHECK_EQUAL(bfus::at_c<0>(res), 999);
+    BOOST_CHECK_EQUAL(bfus::at_c<1>(res), 111);
+    res = bith::wait_for_all(ae, simple_thread2, simple_thread);
+    bfus::for_each(res, print_xml());
+    BOOST_CHECK_EQUAL(bfus::at_c<0>(res), 111);
+    BOOST_CHECK_EQUAL(bfus::at_c<1>(res), 999);
+}
+
+
+///////////////
+
+template <typename AE>
+void do_test_member_fork_detach(AE& ae) {
+    test_value=0;
+
+    BOOST_AUTO(act,ae.fork(simple_thread));
+    BOOST_CHECK_EQUAL(act.interruption_requested(), false);
+    BOOST_CHECK_EQUAL(act.is_ready(), false);
+    BOOST_CHECK_EQUAL(act.has_value(), false);
+    BOOST_CHECK_EQUAL(act.has_exception(), false);
+    BOOST_CHECK_EQUAL(act.joinable(), true);
+    act.detach();
+    BOOST_CHECK_EQUAL(act.joinable(), false);
+    int res_value = act.get();
+    BOOST_CHECK_EQUAL(test_value, 999);
+    BOOST_CHECK_EQUAL(res_value, 999);
+}    
+
+template <typename AE>
+void do_test_join_all(AE& ae) {
+    BOOST_AUTO(tple,bith::fork_all(ae, simple_thread, simple_thread));
+    bith::join_all(tple);    
+}
+
+
+
+template <typename AE>
+void do_test_thread_interrupts_at_interruption_point(AE& ae) {
+    boost::mutex m;
+    bool failed=false;
+    boost::mutex::scoped_lock lk(m);
+    BOOST_AUTO(act,bith::fork(ae, interruption_point_thread, &m,&failed));
+    act.interrupt();
+    BOOST_CHECK_EQUAL(act.interruption_requested(), true);
+    lk.unlock();
+    act.wait();
+    BOOST_CHECK(!failed);
+}    
+}
+#endif
Modified: sandbox/interthreads/libs/interthreads/test/test_basic_threader.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/test_basic_threader.cpp	(original)
+++ sandbox/interthreads/libs/interthreads/test/test_basic_threader.cpp	2009-01-14 12:36:46 EST (Wed, 14 Jan 2009)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Vicente J. Botet Escriba 2008. Distributed under the Boost
+// (C) Copyright Vicente J. Botet Escriba 2008-20009. Distributed under the Boost
 // Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 //
@@ -8,63 +8,88 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
-#include "boost/interthreads/basic_threader.hpp"
+#include "boost/interthreads/typeof/basic_threader.hpp"
+#include "boost/interthreads/algorithm.hpp"
 
 #include <iostream>
 #include <boost/test/unit_test.hpp>
 
+#include <libs/interthreads/test/data_types.hpp>
+#include <libs/interthreads/test/test_ae.hpp>
+
 using namespace boost::unit_test;
 namespace bith = boost::interthreads;
+namespace bfus = boost::fusion;
 
-int test_value;
-void simple_thread() {
-    test_value=999;
-}
 
-void simple_thread_1(unsigned i) {
-    test_value=i;
-}
-
-void test_dir_fork() {
-    bith::basic_threader thr;
+void do_test_member_fork_move() {
+    bith::basic_threader ae;
+    #if 0
+    aetst::do_test_member_fork_move(ae);
+    return;
+    #endif
     test_value=0;
-	boost::thread thrd = thr.fork(simple_thread);
-    thrd.join();
+	boost::thread act(ae.fork(simple_thread));
+    act.join();
     BOOST_CHECK_EQUAL(test_value, 999);
 }    
 
-void test_dir_fork_1() {
-    bith::basic_threader thr;
+void do_test_member_fork_bind() {
+    bith::basic_threader ae;
+    #if 0
+    aetst::do_test_member_fork_bind(ae);
+    return;
+    #endif
     test_value=0;
-	boost::thread thrd = thr.fork(boost::bind(simple_thread_1, 2));
-    thrd.join();
+	boost::thread act(ae.fork(boost::bind(simple_thread_1, 2)));
+    act.join();
     BOOST_CHECK_EQUAL(test_value, 2);
 }    
 
-void test_indir_fork() {
-    bith::basic_threader thr;
+void do_test_fork() {
+    bith::basic_threader ae;
+    #if 0
+    aetst::do_test_fork(ae);
+    return;
+    #endif
     test_value=0;
-	boost::thread thrd = bith::fork(thr, simple_thread);
-    thrd.join();
+	boost::thread act = bith::fork(ae, simple_thread);
+    act.join();
     BOOST_CHECK_EQUAL(test_value, 999);
 }    
 
-void test_indir_fork_1() {
-    bith::basic_threader thr;
+void do_test_fork_1() {
+    bith::basic_threader ae;
+    #if 0
+    aetst::do_test_fork_1(ae);
+    return;
+    #endif
     test_value=0;
-	boost::thread thrd = fork(thr, simple_thread_1, 2);
-    thrd.join();
+	boost::thread act = bith::fork(ae, simple_thread_1, 2);
+    act.join();
     BOOST_CHECK_EQUAL(test_value, 2);
 }    
 
+#if 0
+// this do not works because boost::thread is not movable-only and boost::fusion::tuple works only with CopyContructible types
+void do_test_join_all() {
+    bith::basic_threader ae;
+    typedef bith::result_of::fork_all<bith::basic_threader,bfus::tuple<void(*)(),void(*)()> >::type type;
+    type handles = bith::fork_all(ae, simple_thread, simple_thread);
+    //BOOST_AUTO(handles,bith::fork_all(ae, simple_thread, simple_thread));
+    bith::join_all(tple);
+    
+}
+#endif
 
 test_suite* init_unit_test_suite(int, char*[])
 {
-  test_suite* test = BOOST_TEST_SUITE("basic_threader");
-  test->add(BOOST_TEST_CASE(&test_dir_fork));
-  test->add(BOOST_TEST_CASE(&test_dir_fork_1));
-  test->add(BOOST_TEST_CASE(&test_indir_fork));
-  test->add(BOOST_TEST_CASE(&test_indir_fork_1));
+    test_suite* test = BOOST_TEST_SUITE("basic_threader");
+    test->add(BOOST_TEST_CASE(&do_test_member_fork_move));
+    test->add(BOOST_TEST_CASE(&do_test_member_fork_bind));
+    test->add(BOOST_TEST_CASE(&do_test_fork));
+    test->add(BOOST_TEST_CASE(&do_test_fork_1));
+    //test->add(BOOST_TEST_CASE(&do_test_join_all));
   return test;
 }
 
Modified: sandbox/interthreads/libs/interthreads/test/test_launcher.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/test_launcher.cpp	(original)
+++ sandbox/interthreads/libs/interthreads/test/test_launcher.cpp	2009-01-14 12:36:46 EST (Wed, 14 Jan 2009)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Vicente J. Botet Escriba 2008. Distributed under the Boost
+// (C) Copyright Vicente J. Botet Escriba 2008-20009. Distributed under the Boost
 // Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 //
@@ -8,69 +8,135 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
-#include "boost/interthreads/launcher.hpp"
+#include <boost/interthreads/typeof/launcher.hpp>
+#include <boost/interthreads/typeof/future.hpp>
+#include <boost/interthreads/algorithm.hpp>
 
 #include <iostream>
 #include <boost/test/unit_test.hpp>
+#include <libs/interthreads/test/data_types.hpp>
+#include <libs/interthreads/test/test_ae.hpp>
 
 using namespace boost::unit_test;
 namespace bith = boost::interthreads;
+namespace bfus = boost::fusion;
 
-int test_value;
-int simple_thread() {
-    test_value=999;
-    return test_value;
+void do_test_member_fork() {
+    bith::shared_launcher ae;
+    aetst::do_test_member_fork(ae);
 }
 
-int simple_thread_1(unsigned i) {
-    test_value=i;
-    return test_value;
+void do_test_member_fork_move_unique() {
+    bith::launcher ae;
+    aetst::do_test_member_fork_move(ae);
+}
+void do_test_member_fork_move() {
+    bith::shared_launcher ae;
+    aetst::do_test_member_fork_move(ae);
 }
 
-void test_dir_fork() {
-    bith::launcher ae;
-    test_value=0;
-	boost::unique_future<int> fut  = ae.fork(simple_thread);
-    int res_value = fut.get();
-    BOOST_CHECK_EQUAL(test_value, 999);
-    BOOST_CHECK_EQUAL(res_value, 999);
-}    
+void do_test_member_fork_bind() {
+    bith::shared_launcher ae;
+    aetst::do_test_member_fork_bind(ae);
+}
 
-void test_dir_fork_1() {
+void do_test_member_fork_bind_move() {
     bith::launcher ae;
     test_value=0;
         boost::unique_future<int> fut  = ae.fork(boost::bind(simple_thread_1, 2));
     int res_value = fut.get();
     BOOST_CHECK_EQUAL(test_value, 2);
     BOOST_CHECK_EQUAL(res_value, 2);
-}    
+}
+
+void do_test_fork() {
+    bith::shared_launcher ae;
+    aetst::do_test_fork(ae);
+}
 
-void test_indir_fork() {
+void do_test_fork_move() {
     bith::launcher ae;
     test_value=0;
-	boost::unique_future<int> fut = bith::fork(ae, simple_thread);
+    boost::unique_future<int> fut = bith::fork(ae, simple_thread);
     int res_value = fut.get();
     BOOST_CHECK_EQUAL(test_value, 999);
     BOOST_CHECK_EQUAL(res_value, 999);
-}    
+}
 
-void test_indir_fork_1() {
+void do_test_fork_1() {
+    bith::shared_launcher ae;
+    aetst::do_test_fork_1(ae);
+}
+void do_test_fork_1_move() {
     bith::launcher ae;
     test_value=0;
-	boost::unique_future<int> fut = fork(ae, simple_thread_1, 2);
+    boost::unique_future<int> fut = fork(ae, simple_thread_1, 2);
     int res_value = fut.get();
     BOOST_CHECK_EQUAL(test_value, 2);
     BOOST_CHECK_EQUAL(res_value, 2);
-}    
+}
 
+void do_test_creation_through_functor()
+{
+    bith::shared_launcher ae;
+    aetst::do_test_creation_through_functor(ae);
+}
+
+void do_test_creation_through_functor_move()
+{
+    bith::launcher ae;
+    copyable_functor f;
+    boost::unique_future<int> act=bith::fork(ae, f);
+    
+    int res = act.get();
+    BOOST_CHECK_EQUAL(res, 999);
+}
+
+void do_test_creation_through_reference_wrapper()
+{
+    bith::shared_launcher ae;
+    aetst::do_test_creation_through_reference_wrapper(ae);
+}
+
+void do_test_wait_all() {
+    bith::shared_launcher ae;
+    aetst::do_test_wait_all(ae);
+}
+
+void do_test_wait_for_any() {
+    bith::shared_launcher ae;
+    aetst::do_test_wait_for_any(ae);
+}
+
+void do_test_set_all() {
+    bith::shared_launcher ae;
+    aetst::do_test_set_all(ae);
+}
+
+void do_test_wait_for_all() {
+    bith::shared_launcher ae;
+    aetst::do_test_wait_for_all(ae);
+}
 
 test_suite* init_unit_test_suite(int, char*[])
 {
-  test_suite* test = BOOST_TEST_SUITE("launcher");
-  test->add(BOOST_TEST_CASE(&test_dir_fork));
-  test->add(BOOST_TEST_CASE(&test_dir_fork_1));
-  test->add(BOOST_TEST_CASE(&test_indir_fork));
-  test->add(BOOST_TEST_CASE(&test_indir_fork_1));
-  return test;
+    test_suite* test = BOOST_TEST_SUITE("launcher");
+    test->add(BOOST_TEST_CASE(&do_test_member_fork_move));
+    
+    test->add(BOOST_TEST_CASE(&do_test_member_fork));
+    test->add(BOOST_TEST_CASE(&do_test_member_fork_move));
+    test->add(BOOST_TEST_CASE(&do_test_member_fork_bind));
+    test->add(BOOST_TEST_CASE(&do_test_member_fork_bind_move));
+    test->add(BOOST_TEST_CASE(&do_test_fork));
+    test->add(BOOST_TEST_CASE(&do_test_fork_move));
+    test->add(BOOST_TEST_CASE(&do_test_fork_1));
+    test->add(BOOST_TEST_CASE(&do_test_fork_1_move));
+    test->add(BOOST_TEST_CASE(&do_test_creation_through_functor));
+    test->add(BOOST_TEST_CASE(&do_test_creation_through_reference_wrapper));
+    test->add(BOOST_TEST_CASE(&do_test_wait_all));
+    test->add(BOOST_TEST_CASE(&do_test_wait_for_any));
+    test->add(BOOST_TEST_CASE(&do_test_set_all));
+    test->add(BOOST_TEST_CASE(&do_test_wait_for_all));
+    return test;
 }
 
Modified: sandbox/interthreads/libs/interthreads/test/test_thread_decorator.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/test_thread_decorator.cpp	(original)
+++ sandbox/interthreads/libs/interthreads/test/test_thread_decorator.cpp	2009-01-14 12:36:46 EST (Wed, 14 Jan 2009)
@@ -1,7 +1,7 @@
 //////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Roland Schwarz 2006. 
-// (C) Copyright Vicente J. Botet Escriba 2008. 
+// (C) Copyright Vicente J. Botet Escriba 2008-20009. 
 // Distributed under the Boost Software License, Version 1.0. 
 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 //
Added: sandbox/interthreads/libs/interthreads/test/test_thread_pool.cpp
==============================================================================
--- (empty file)
+++ sandbox/interthreads/libs/interthreads/test/test_thread_pool.cpp	2009-01-14 12:36:46 EST (Wed, 14 Jan 2009)
@@ -0,0 +1,126 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2008-20009. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/sync for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+    
+#include "boost/fusion/include/vector_tie.hpp"
+#include "boost/thread/thread_time.hpp"
+#include "boost/thread/mutex.hpp"
+#include "boost/thread/locks.hpp"
+#include <boost/thread/xtime.hpp>
+#include "boost/interthreads/typeof/launcher.hpp"
+#include "boost/interthreads/typeof/threader.hpp"
+#include "boost/interthreads/typeof/scheduler.hpp"
+#include "boost/interthreads/typeof/future.hpp"
+#include "boost/interthreads/algorithm.hpp"
+#include <boost/typeof/typeof.hpp>
+#include <libs/interthreads/test/data_types.hpp>
+#include <libs/interthreads/test/test_ae.hpp>
+
+#include <iostream>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/static_assert.hpp>
+#include <boost/type_traits.hpp>
+#include <boost/tp/unbounded_channel.hpp>
+#include <boost/tp/fifo.hpp>
+
+
+using namespace boost::unit_test;
+namespace bith = boost::interthreads;
+namespace bfus = boost::fusion;
+
+#define SCHEDULER
+
+#if SCHEDULER
+typedef bith::scheduler<
+  boost::tp::unbounded_channel< boost::tp::fifo >
+> pool_type;
+#else
+typedef boost::tp::pool<
+  boost::tp::unbounded_channel< boost::tp::fifo >
+> pool_type;
+#endif
+
+void do_test_member_fork() {  
+    boost::tp::poolsize s(2);
+    pool_type ae(s);
+    aetst::do_test_member_fork(ae);
+}    
+
+
+void do_test_member_fork_bind() {
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_member_fork_bind(ae);
+}    
+void do_test_fork() {
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_fork(ae);
+}    
+
+void do_test_fork_1() {
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_fork_1(ae);
+}    
+
+void do_test_creation_through_reference_wrapper()
+{
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_creation_through_reference_wrapper(ae);
+}
+
+void do_test_creation_through_functor()
+{
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_creation_through_functor(ae);
+}
+
+
+void do_test_thread_interrupts_at_interruption_point() {
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_thread_interrupts_at_interruption_point(ae);
+}    
+
+void do_test_wait_all() {
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_wait_all(ae);
+}
+
+void do_test_wait_for_any() {
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_wait_for_any(ae);
+}
+
+void do_test_set_all() {
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_set_all(ae);
+}
+
+void do_test_wait_for_all() {
+    pool_type ae(boost::tp::poolsize(2));
+    aetst::do_test_wait_for_all(ae);
+}
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+    test_suite* test = BOOST_TEST_SUITE("shared_threader");
+    
+    test->add(BOOST_TEST_CASE(&do_test_member_fork));
+    test->add(BOOST_TEST_CASE(&do_test_member_fork_bind));
+    test->add(BOOST_TEST_CASE(&do_test_fork));
+    test->add(BOOST_TEST_CASE(&do_test_fork_1));
+    test->add(BOOST_TEST_CASE(&do_test_thread_interrupts_at_interruption_point));
+    test->add(BOOST_TEST_CASE(&do_test_creation_through_functor));
+    test->add(BOOST_TEST_CASE(&do_test_creation_through_reference_wrapper));
+    test->add(BOOST_TEST_CASE(&do_test_wait_all));
+    //test->add(BOOST_TEST_CASE(&do_test_wait_for_any));  FAILS
+    test->add(BOOST_TEST_CASE(&do_test_set_all));
+    test->add(BOOST_TEST_CASE(&do_test_wait_for_all));
+  return test;
+}
Modified: sandbox/interthreads/libs/interthreads/test/test_thread_shared_ptr.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/test_thread_shared_ptr.cpp	(original)
+++ sandbox/interthreads/libs/interthreads/test/test_thread_shared_ptr.cpp	2009-01-14 12:36:46 EST (Wed, 14 Jan 2009)
@@ -1,7 +1,7 @@
 //////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Roland Schwarz 2006. 
-// (C) Copyright Vicente J. Botet Escriba 2008. 
+// (C) Copyright Vicente J. Botet Escriba 2008-20009. 
 // Distributed under the Boost Software License, Version 1.0. 
 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 //
Modified: sandbox/interthreads/libs/interthreads/test/test_threader.cpp
==============================================================================
--- sandbox/interthreads/libs/interthreads/test/test_threader.cpp	(original)
+++ sandbox/interthreads/libs/interthreads/test/test_threader.cpp	2009-01-14 12:36:46 EST (Wed, 14 Jan 2009)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Vicente J. Botet Escriba 2008. Distributed under the Boost
+// (C) Copyright Vicente J. Botet Escriba 2008-20009. Distributed under the Boost
 // Software License, Version 1.0. (See accompanying file
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 //
@@ -9,205 +9,179 @@
 //////////////////////////////////////////////////////////////////////////////
 
     
+#include "boost/fusion/include/vector_tie.hpp"
 #include "boost/thread/thread_time.hpp"
 #include "boost/thread/mutex.hpp"
 #include "boost/thread/locks.hpp"
 #include <boost/thread/xtime.hpp>
-#include "boost/interthreads/threader.hpp"
+#include "boost/interthreads/typeof/launcher.hpp"
+#include "boost/interthreads/typeof/threader.hpp"
+#include "boost/interthreads/typeof/future.hpp"
 #include "boost/interthreads/algorithm.hpp"
+#include <boost/typeof/typeof.hpp>
+#include <libs/interthreads/test/data_types.hpp>
+#include <libs/interthreads/test/test_ae.hpp>
 
 #include <iostream>
 #include <boost/test/unit_test.hpp>
 
+#include <boost/static_assert.hpp>
+#include <boost/type_traits.hpp>
+
 using namespace boost::unit_test;
 namespace bith = boost::interthreads;
+namespace bfus = boost::fusion;
 
-namespace
-{
-inline boost::xtime delay(int secs, int msecs=0, int nsecs=0)
-{
-    const int MILLISECONDS_PER_SECOND = 1000;
-    const int NANOSECONDS_PER_SECOND = 1000000000;
-    const int NANOSECONDS_PER_MILLISECOND = 1000000;
 
-    boost::xtime xt;
-    if (boost::TIME_UTC != boost::xtime_get (&xt, boost::TIME_UTC))
-        BOOST_ERROR ("boost::xtime_get != boost::TIME_UTC");
 
-    nsecs += xt.nsec;
-    msecs += nsecs / NANOSECONDS_PER_MILLISECOND;
-    secs += msecs / MILLISECONDS_PER_SECOND;
-    nsecs += (msecs % MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND;
-    xt.nsec = nsecs % NANOSECONDS_PER_SECOND;
-    xt.sec += secs + (nsecs / NANOSECONDS_PER_SECOND);
-
-    return xt;
-}
+void do_test_member_fork_detach() {
+    bith::shared_threader ae;
+    aetst::do_test_member_fork_detach(ae);
 }
 
-void sleep(int sec)
-{
-	boost::xtime t;
-	boost::xtime_get(&t,1);	
-    t.sec += sec; 
-    boost::thread::sleep(t);
-}
-
-int test_value;
-int simple_thread() {
-    test_value=999;
-    sleep(3);
-    return test_value;
-}
-
-int simple_thread_1(unsigned i) {
-    test_value=i;
-    sleep(5);
-    return test_value;
-}
-
-
-void test_dir_fork() {
-    bith::threader ae;
-    test_value=0;
-	bith::joiner<int> act  = ae.fork(simple_thread);
-    BOOST_CHECK_EQUAL(act.interruption_requested(), false);
-    BOOST_CHECK_EQUAL(act.is_ready(), false);
-    BOOST_CHECK_EQUAL(act.has_value(), false);
-    BOOST_CHECK_EQUAL(act.has_exception(), false);
-    BOOST_CHECK_EQUAL(act.joinable(), true);
-    act.detach();
-    BOOST_CHECK_EQUAL(act.joinable(), false);
-    int res_value = act.get();
-    BOOST_CHECK_EQUAL(test_value, 999);
-    BOOST_CHECK_EQUAL(res_value, 999);
+void do_test_member_fork() {  
+    bith::shared_threader ae;
+    aetst::do_test_member_fork(ae);
 }    
 
-void test_dir_fork_1() {
-    bith::threader ae;
-    test_value=0;
-	bith::joiner<int> act  = ae.fork(boost::bind(simple_thread_1, 2));
-    act.join();
-    int res_value = act.get();
-    BOOST_CHECK_EQUAL(test_value, 2);
-    BOOST_CHECK_EQUAL(res_value, 2);
+void do_test_member_fork_move_unique() {
+    bith::unique_threader ae;
+    aetst::do_test_member_fork_move(ae);
+}
+
+void do_test_member_fork_bind() {
+    bith::shared_threader ae;
+    aetst::do_test_member_fork_bind(ae);
 }    
 
-void test_indir_fork() {
-    bith::threader ae;
-    test_value=0;
-	bith::joiner<int> act = bith::fork(ae, simple_thread);
-    act.join_until(delay(6));
-    int res_value = act.get();
-    BOOST_CHECK_EQUAL(test_value, 999);
-    BOOST_CHECK_EQUAL(res_value, 999);
+void do_test_fork() {
+    bith::shared_threader ae;
+    aetst::do_test_fork(ae);
 }    
 
-void test_indir_fork_1() {
-    bith::threader ae;
-    test_value=0;
-	bith::joiner<int> act = bith::fork(ae, simple_thread_1, 2);
-    //act.wait_until( boost::get_system_time()+boost::posix_time::seconds(6));
-    act.wait_for( boost::posix_time::seconds(6));
-    BOOST_CHECK_EQUAL(act.is_ready(), true);
-    BOOST_CHECK_EQUAL(act.has_value(), true);
-    BOOST_CHECK_EQUAL(act.has_exception(), false);
-    int res_value = act.get();
-    BOOST_CHECK_EQUAL(test_value, 2);
-    BOOST_CHECK_EQUAL(res_value, 2);
+void do_test_fork_1() {
+    bith::shared_threader ae;
+    aetst::do_test_fork_1(ae);
 }    
 
-struct non_copyable_functor
-    :    boost::noncopyable
-{
-    unsigned value;
-    typedef unsigned result_type;
-    
-    non_copyable_functor():
-        value(0)
-    {}
-    
-    unsigned operator()()
-    {
-        value=999;
-        return value;
-    }
-};
 void do_test_creation_through_reference_wrapper()
 {
-    bith::threader ae;
-    non_copyable_functor f;
-	bith::joiner<unsigned> act = bith::fork(ae, boost::bind(boost::ref(f)));
-    
-    unsigned res = act.get();
-    BOOST_CHECK_EQUAL(res, 999u);
-    BOOST_CHECK_EQUAL(f.value, 999u);
+    bith::shared_threader ae;
+    aetst::do_test_creation_through_reference_wrapper(ae);
 }
 
-struct copyable_functor
-//    :    std::nullary_function<int>
-{
-    unsigned value;
-    typedef int result_type;
-    
-    copyable_functor():
-        value(0)
-    {}
-    
-    int operator()()
-    {
-        value=999;
-        return value;
-    }
-};
 void do_test_creation_through_functor()
 {
-    bith::threader ae;
-    copyable_functor f;
-	bith::joiner<int> act = bith::fork(ae, f);
-    
-    int res = act.get();
-    BOOST_CHECK_EQUAL(res, 999);
+    bith::shared_threader ae;
+    aetst::do_test_creation_through_functor(ae);
 }
 
-bool interruption_point_thread(boost::mutex* m,bool* failed)
-{
-    boost::mutex::scoped_lock lk(*m);
-    boost::this_thread::interruption_point();
-    *failed=true;
-    return failed;
-}
 
 void do_test_thread_interrupts_at_interruption_point() {
-    bith::threader ae;
-    boost::mutex m;
-    bool failed=false;
-    boost::mutex::scoped_lock lk(m);
-	bith::joiner<bool> act = bith::fork(ae, interruption_point_thread, &m,&failed);
-    act.interrupt();
-    BOOST_CHECK_EQUAL(act.interruption_requested(), true);
-    lk.unlock();
-    act.join();
-    BOOST_CHECK(!failed);
+    bith::shared_threader ae;
+    aetst::do_test_thread_interrupts_at_interruption_point(ae);
 }    
 
-void do_test_fork_all() {
-    bith::threader ae;
-//	bith::result_of::fork_all<bith::threader,simple_thread,simple_thread_1(unsigned)> tple = 
-//        bith::fork_all(ae, simple_thread, boost::bind(simple_thread_1, 2));
-    
+void do_test_join_all() {
+    bith::shared_threader ae;
+    aetst::do_test_join_all(ae);    
+}
+void do_test_wait_all() {
+    bith::shared_threader ae;
+    aetst::do_test_wait_all(ae);
+}
+
+void do_test_wait_for_any() {
+    bith::shared_threader ae;
+    aetst::do_test_wait_for_any(ae);
+}
+
+void do_test_wait_for_any2() {
+    boost::packaged_task<int> tsk1(simple_thread);
+    boost::unique_future<int> res1 = tsk1.get_future();
+    boost::thread th1(boost::move(tsk1));
+    boost::packaged_task<int> tsk2(simple_thread2);
+    boost::unique_future<int> res2 = tsk2.get_future();
+    boost::thread th2(boost::move(tsk2));
+    unsigned res = boost::wait_for_any(res1, res2);
+    
+    BOOST_CHECK_EQUAL(res, 0u);
+}
+
+void do_test_wait_for_any3() {
+    bith::shared_threader ae;
+    typedef bith::shared_threader  AE;
+    typedef bith::result_of::fork_all<bith::shared_threader,bfus::tuple<int(*)(),int(*)()> >::type type;   
+    type tple = bith::fork_all(ae, simple_thread, simple_thread);
+    unsigned r = boost::wait_for_any(
+        bith::get_future<AE>()(bfus::at_c<0>(tple)), 
+        bith::get_future<AE>()(bfus::at_c<1>(tple)));
+    int val;
+    switch (r) {
+        case 0:
+            val = bfus::at_c<0>(tple).get();
+            break;
+        case 1:
+            val = bfus::at_c<1>(tple).get();
+            break;
+        default:;
+            //throw std::range_error("");
+    }
+    bith::interrupt_all(tple);
+    BOOST_CHECK_EQUAL(r, 0u);
+}
+
+void do_test_other() {
+    boost::packaged_task<int> tsk1(simple_thread);
+    boost::packaged_task<int> tsk2(simple_thread2);
+    boost::unique_future<int> res1 = tsk1.get_future();
+    //BOOST_AUTO(res1,tsk1.get_future());
+    boost::unique_future<int> res2 = tsk2.get_future();
+    boost::thread th1(boost::move(tsk1));
+    boost::thread th2(boost::move(tsk2));
+
+}
+
+void do_test_get_all() {
+    bith::shared_threader ae;
+    typedef bith::result_of::fork_all<bith::shared_threader,bfus::tuple<int(*)(),int(*)()> >::type auto_type;
+    //auto_type tple = bith::fork_all(ae, simple_thread, simple_thread);
+    BOOST_AUTO(tple,bith::fork_all(ae, simple_thread, simple_thread));
+    bith::wait_all(tple);
+    BOOST_AUTO(res,bith::get_all(tple));   
+    //bfus::for_each(res, print_xml());
+}
+
+void do_test_set_all() {
+    bith::shared_threader ae;
+    aetst::do_test_set_all(ae);
+}
+
+void do_test_wait_for_all() {
+    bith::shared_threader ae;
+    aetst::do_test_wait_for_all(ae);
 }
 
 test_suite* init_unit_test_suite(int, char*[])
 {
-  test_suite* test = BOOST_TEST_SUITE("threader");
-  test->add(BOOST_TEST_CASE(&test_dir_fork));
-  test->add(BOOST_TEST_CASE(&test_dir_fork_1));
-  test->add(BOOST_TEST_CASE(&test_indir_fork));
-  test->add(BOOST_TEST_CASE(&test_indir_fork_1));
-  test->add(BOOST_TEST_CASE(&do_test_thread_interrupts_at_interruption_point));
-  test->add(BOOST_TEST_CASE(&do_test_creation_through_functor));
-  test->add(BOOST_TEST_CASE(&do_test_creation_through_reference_wrapper));
-  test->add(BOOST_TEST_CASE(&do_test_fork_all));
+    test_suite* test = BOOST_TEST_SUITE("shared_threader");
+    
+    test->add(BOOST_TEST_CASE(&do_test_member_fork_detach));
+    test->add(BOOST_TEST_CASE(&do_test_member_fork));
+    test->add(BOOST_TEST_CASE(&do_test_member_fork_bind));
+    test->add(BOOST_TEST_CASE(&do_test_fork));
+    test->add(BOOST_TEST_CASE(&do_test_fork_1));
+    test->add(BOOST_TEST_CASE(&do_test_thread_interrupts_at_interruption_point));
+    test->add(BOOST_TEST_CASE(&do_test_creation_through_functor));
+    test->add(BOOST_TEST_CASE(&do_test_creation_through_reference_wrapper));
+    test->add(BOOST_TEST_CASE(&do_test_wait_all));
+    test->add(BOOST_TEST_CASE(&do_test_wait_for_any2));
+    test->add(BOOST_TEST_CASE(&do_test_join_all));
+    test->add(BOOST_TEST_CASE(&do_test_wait_for_any));
+    test->add(BOOST_TEST_CASE(&do_test_set_all));
+    test->add(BOOST_TEST_CASE(&do_test_wait_for_all));
+    #if 0
+    //test->add(BOOST_TEST_CASE(&do_test_get_all));
+    #endif
   return test;
 }