|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54127 - in sandbox/task: . boost/task boost/task/detail libs/task/doc libs/task/test
From: oliver.kowalke_at_[hidden]
Date: 2009-06-20 16:10:04
Author: olli
Date: 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
New Revision: 54127
URL: http://svn.boost.org/trac/boost/changeset/54127
Log:
* task< R > ctors for functions wit harguments
* tests enhanced
Text files modified:
sandbox/task/boost/task/detail/bind_processor_freebsd.hpp | 12 +-
sandbox/task/boost/task/static_pool.hpp | 19 +++
sandbox/task/boost/task/task.hpp | 28 +++++
sandbox/task/change.log | 4
sandbox/task/libs/task/doc/ref_static_pool.qbk | 12 ++
sandbox/task/libs/task/doc/static_pool.qbk | 2
sandbox/task/libs/task/test/test_bounded_pool.cpp | 220 +++++++++++++++-----------------------
sandbox/task/libs/task/test/test_new_thread.cpp | 91 ++++------------
sandbox/task/libs/task/test/test_own_thread.cpp | 96 ++++------------
sandbox/task/libs/task/test/test_task.cpp | 20 --
sandbox/task/libs/task/test/test_unbounded_pool.cpp | 224 +++++++++++++++------------------------
11 files changed, 293 insertions(+), 435 deletions(-)
Modified: sandbox/task/boost/task/detail/bind_processor_freebsd.hpp
==============================================================================
--- sandbox/task/boost/task/detail/bind_processor_freebsd.hpp (original)
+++ sandbox/task/boost/task/detail/bind_processor_freebsd.hpp 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -26,12 +26,12 @@
{
BOOST_ASSERT( n >= 0);
BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
-
+
cpuset_t cpuset;
CPU_ZERO( & cpuset);
CPU_SET( n, & cpuset);
-
- if ( ::cpuset_setaffinity( CPU_LEVEL_CPUSET, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1)
+
+ if ( ::cpuset_setaffinity( CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1)
throw boost::system::system_error(
boost::system::error_code(
errno,
@@ -43,12 +43,12 @@
{
cpuset_t cpuset;
CPU_ZERO( & cpuset);
-
+
unsigned int max( boost::thread::hardware_concurrency() );
for ( unsigned int i( 0); i < max; ++i)
CPU_SET( i, & cpuset);
-
- if ( ::cpuset_setaffinity( CPU_LEVEL_CPUSET, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1)
+
+ if ( ::cpuset_setaffinity( CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1)
throw boost::system::system_error(
boost::system::error_code(
errno,
Modified: sandbox/task/boost/task/static_pool.hpp
==============================================================================
--- sandbox/task/boost/task/static_pool.hpp (original)
+++ sandbox/task/boost/task/static_pool.hpp 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -261,7 +261,15 @@
shared_lock< shared_mutex > lk( mtx_wg_);
return idle_();
}
-
+
+ void interrupt_all_worker()
+ {
+ if ( closed_() ) return;
+
+ shared_lock< shared_mutex > lk( mtx_wg_);
+ wg_.interrupt_all();
+ }
+
void shutdown()
{
if ( closed_() || close_() > 1) return;
@@ -441,7 +449,14 @@
throw pool_moved();
return pool_->idle();
}
-
+
+ void interrupt_all_worker()
+ {
+ if ( ! pool_)
+ throw pool_moved();
+ pool_->interrupt_all_worker();
+ }
+
void shutdown()
{
if ( ! pool_)
Modified: sandbox/task/boost/task/task.hpp
==============================================================================
--- sandbox/task/boost/task/task.hpp (original)
+++ sandbox/task/boost/task/task.hpp 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -9,8 +9,10 @@
#include <boost/bind.hpp>
#include <boost/config.hpp>
+#include <boost/preprocessor/repetition.hpp>
#include <boost/thread.hpp>
#include <boost/utility/enable_if.hpp>
+#include <boost/utility/result_of.hpp>
#include <boost/task/future.hpp>
#include <boost/task/exceptions.hpp>
@@ -247,6 +249,32 @@
{ return boost::detail::thread_move_t< task >( * this); }
# endif
+# ifndef BOOST_TASK_MAKE_TASK_MAX_ARITY
+# define BOOST_TASK_MAKE_TASK_MAX_ARITY 10
+# endif
+
+# define BOOST_TASK_MAKE_TASK_FUNC_ARG(z, n, unused) \
+ BOOST_PP_CAT(A, n) BOOST_PP_CAT(a, n)
+# define BOOST_ENUM_TASK_MAKE_TASK_FUNC_ARGS(n) BOOST_PP_ENUM(n, BOOST_TASK_MAKE_TASK_FUNC_ARG, ~)
+
+# define BOOST_TASK_MAKE_TASK_FUNCTION(z, n, unused) \
+template< \
+ typename Fn, \
+ BOOST_PP_ENUM_PARAMS(n, typename A) \
+> \
+explicit task( Fn fn, BOOST_ENUM_TASK_MAKE_TASK_FUNC_ARGS(n)) \
+ : task_( new detail::task_wrapper< \
+ typename result_of< Fn( BOOST_PP_ENUM_PARAMS(n, A)) >::type, \
+ function< typename result_of< Fn( BOOST_PP_ENUM_PARAMS(n, A)) >::type() > \
+ >( bind( fn, BOOST_PP_ENUM_PARAMS(n, a)) ) ) \
+ {}
+
+BOOST_PP_REPEAT_FROM_TO( 1, BOOST_TASK_MAKE_TASK_MAX_ARITY, BOOST_TASK_MAKE_TASK_FUNCTION, ~)
+
+# undef BOOST_TASK_MAKE_TASK_FUNCTION
+# undef BOOST_TASK_MAKE_TASK_FUNC_ARG
+# undef BOOST_ENUM_TASK_MAKE_TASK_FUNC_ARGS
+
unique_future< R > get_future()
{
if ( ! task_)
Modified: sandbox/task/change.log
==============================================================================
--- sandbox/task/change.log (original)
+++ sandbox/task/change.log 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -8,7 +8,9 @@
boolean indicating if op. succeeded or timed out
- move sematics for task< R >
- move sematics for static_pool< R >
-- default_pool) removed because thread_resource_error exceptions thrown by static pool
+- new function interrupt_all_worker() for static_pool< Channel > in order to interrupt all
+ worker-threads without invalidating the pool
+- default_pool() removed because thread_resource_error exceptions thrown by static pool
- tests updated
- examples updated
- documentation updated
Modified: sandbox/task/libs/task/doc/ref_static_pool.qbk
==============================================================================
--- sandbox/task/libs/task/doc/ref_static_pool.qbk (original)
+++ sandbox/task/libs/task/doc/ref_static_pool.qbk 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -58,6 +58,8 @@
void shutdown();
void shutdown_now();
+ void interrupt_all_worker();
+
bool closed();
void clear();
bool empty();
@@ -243,6 +245,16 @@
]
+[heading Member function `interrupt_all_worker()`]
+
+ void interrupt_all_worker()
+
+[variablelist
+[[Effects:] [interrupts all worker-threads without invalidating the pool]]
+[[Throws:] [nothing]]
+]
+
+
[heading Member function `closed()`]
bool closed()
Modified: sandbox/task/libs/task/doc/static_pool.qbk
==============================================================================
--- sandbox/task/libs/task/doc/static_pool.qbk (original)
+++ sandbox/task/libs/task/doc/static_pool.qbk 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -33,7 +33,7 @@
shutdown and __fn_active__ as well as __fn_idle__ returning how many __worker_threads__ are active (executing a task) or idle.
The size of the pool can be accessed over __fn_size__.
-For infomational pruposes __fn_empty__ and __fn_pending__ can be used in order to know if the global task-queue is empty or
+For informational pruposes __fn_empty__ and __fn_pending__ can be used in order to know if the global task-queue is empty or
how many tasks are waiting for execution. With __fn_clear__ all tasks are removed from the global-queue.
[note __fn_pending__ does not count tasks in the local-queues of the __worker_threads__.]
Modified: sandbox/task/libs/task/test/test_bounded_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_bounded_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_bounded_pool.cpp 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -72,10 +72,7 @@
BOOST_CHECK_EQUAL( pool2.upper_bound(), std::size_t( 10) );
BOOST_CHECK_EQUAL( pool2.lower_bound(), std::size_t( 5) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), pool2) );
BOOST_CHECK_EQUAL( h.get(), 55);
@@ -90,10 +87,7 @@
tsk::poolsize( 1),
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK_EQUAL( h.get(), 55);
@@ -108,10 +102,7 @@
tsk::poolsize( 5),
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h1;
tsk::handle< int > h2(
tsk::async( boost::move( t), pool) );
@@ -129,14 +120,8 @@
tsk::poolsize( 5),
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
- tsk::task< int > t1(
- boost::bind(
- fibonacci_fn,
- 5) );
- tsk::task< int > t2(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t1( fibonacci_fn, 5);
+ tsk::task< int > t2( fibonacci_fn, 10);
tsk::handle< int > h1(
tsk::async( boost::move( t1), pool) );
tsk::handle< int > h2(
@@ -172,10 +157,7 @@
tsk::poolsize( 1),
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), pool) );
pool.shutdown();
@@ -208,10 +190,7 @@
tsk::poolsize( 1),
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
pool.shutdown();
BOOST_CHECK( pool.closed() );
BOOST_CHECK_THROW(
@@ -228,10 +207,7 @@
tsk::poolsize( 1),
tsk::high_watermark( 1),
tsk::low_watermark( 1) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::millisec( 500) ) );
+ tsk::task< void > t( delay_fn, pt::millisec( 500) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
boost::this_thread::sleep( pt::millisec( 250) );
@@ -256,17 +232,14 @@
tsk::low_watermark( 10) );
boost::barrier b( 2);
tsk::task< void > t1(
- boost::bind(
- barrier_fn,
- boost::ref( b) ) );
+ barrier_fn,
+ boost::ref( b) );
tsk::task< int > t2(
- boost::bind(
- fibonacci_fn,
- 10) );
+ fibonacci_fn,
+ 10);
tsk::task< int > t3(
- boost::bind(
- fibonacci_fn,
- 10) );
+ fibonacci_fn,
+ 10);
tsk::handle< void > h1(
tsk::async( boost::move( t1), pool) );
boost::this_thread::sleep( pt::millisec( 250) );
@@ -295,10 +268,7 @@
tsk::poolsize( 5),
tsk::high_watermark( 1),
tsk::low_watermark( 1) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), pool) );
h.wait();
@@ -317,10 +287,7 @@
tsk::poolsize( 5),
tsk::high_watermark( 1),
tsk::low_watermark( 1) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 1) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( h.wait_for( pt::seconds( 3) ) );
@@ -338,10 +305,7 @@
tsk::poolsize( 5),
tsk::high_watermark( 1),
tsk::low_watermark( 1) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( ! h.wait_for( pt::seconds( 1) ) );
@@ -359,10 +323,7 @@
tsk::poolsize( 5),
tsk::high_watermark( 1),
tsk::low_watermark( 1) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 1) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 3) ) );
@@ -380,10 +341,7 @@
tsk::poolsize( 5),
tsk::high_watermark( 1),
tsk::low_watermark( 1) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( ! h.wait_until( boost::get_system_time() + pt::seconds( 1) ) );
@@ -401,10 +359,7 @@
tsk::poolsize( 5),
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
h.interrupt();
@@ -412,7 +367,7 @@
BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
}
- // check interrupt_and_wait
+ // check interrupt_all_worker
void test_case_17()
{
tsk::static_pool<
@@ -421,12 +376,37 @@
tsk::poolsize( 5),
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
+ tsk::task< void > t1( delay_fn, pt::seconds( 3) );
+ tsk::task< void > t2( delay_fn, pt::seconds( 3) );
+ tsk::task< void > t3( delay_fn, pt::seconds( 3) );
+ tsk::handle< void > h1(
+ tsk::async( boost::move( t1), pool) );
+ tsk::handle< void > h2(
+ tsk::async( boost::move( t2), pool) );
+ tsk::handle< void > h3(
+ tsk::async( boost::move( t3), pool) );
+ boost::this_thread::sleep( pt::millisec( 250) );
+ pool.interrupt_all_worker();
+ BOOST_CHECK( ! h1.interruption_requested() );
+ BOOST_CHECK( ! h2.interruption_requested() );
+ BOOST_CHECK( ! h3.interruption_requested() );
+ BOOST_CHECK_THROW( h1.get(), tsk::task_interrupted);
+ BOOST_CHECK_THROW( h2.get(), tsk::task_interrupted);
+ BOOST_CHECK_THROW( h3.get(), tsk::task_interrupted);
+ BOOST_CHECK_EQUAL( pool.size(), std::size_t( 5) );
+ }
+
+ // check interrupt_and_wait
+ void test_case_18()
+ {
+ tsk::static_pool<
+ tsk::bounded_channel< tsk::fifo >
+ > pool(
+ tsk::poolsize( 5),
+ tsk::high_watermark( 10),
+ tsk::low_watermark( 10) );
bool finished( false);
- tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ tsk::task< void > t( interrupt_fn, pt::seconds( 1), boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
h.interrupt_and_wait();
@@ -439,7 +419,7 @@
}
// check interrupt_and_wait_for
- void test_case_18()
+ void test_case_19()
{
tsk::static_pool<
tsk::bounded_channel< tsk::fifo >
@@ -448,11 +428,7 @@
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
bool finished( false);
- tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ tsk::task< void > t( interrupt_fn, pt::seconds( 1), boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 3) ) );
@@ -465,7 +441,7 @@
}
// check interrupt_and_wait_for
- void test_case_19()
+ void test_case_20()
{
tsk::static_pool<
tsk::bounded_channel< tsk::fifo >
@@ -473,17 +449,14 @@
tsk::poolsize( 5),
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
- tsk::task< void > t(
- boost::bind(
- non_interrupt_fn,
- 3) );
+ tsk::task< void > t( non_interrupt_fn, 3);
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( ! h.interrupt_and_wait_for( pt::seconds( 1) ) );
}
// check interrupt_and_wait_until
- void test_case_20()
+ void test_case_21()
{
tsk::static_pool<
tsk::bounded_channel< tsk::fifo >
@@ -493,10 +466,9 @@
tsk::low_watermark( 10) );
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 3) ) );
@@ -509,7 +481,7 @@
}
// check interrupt_and_wait_until
- void test_case_21()
+ void test_case_22()
{
tsk::static_pool<
tsk::bounded_channel< tsk::fifo >
@@ -517,17 +489,14 @@
tsk::poolsize( 5),
tsk::high_watermark( 10),
tsk::low_watermark( 10) );
- tsk::task< void > t(
- boost::bind(
- non_interrupt_fn,
- 3) );
+ tsk::task< void > t( non_interrupt_fn, 3);
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( ! h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 1) ) );
}
// check fifo scheduling
- void test_case_22()
+ void test_case_23()
{
typedef tsk::static_pool<
tsk::bounded_channel< tsk::fifo >
@@ -539,20 +508,15 @@
tsk::low_watermark( 10) );
boost::barrier b( 2);
std::vector< int > buffer;
- tsk::task< void > t1(
- boost::bind(
- barrier_fn,
- boost::ref( b) ) );
+ tsk::task< void > t1( barrier_fn, boost::ref( b) );
tsk::task< void > t2(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 10) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 10);
tsk::task< void > t3(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 0) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 0);
tsk::async( boost::move( t1), pool);
tsk::async( boost::move( t2), pool);
tsk::async( boost::move( t3), pool);
@@ -564,7 +528,7 @@
}
// check priority scheduling
- void test_case_23()
+ void test_case_24()
{
typedef tsk::static_pool<
tsk::bounded_channel< tsk::priority< int > >
@@ -578,20 +542,15 @@
tsk::low_watermark( 10) );
boost::barrier b( 2);
std::vector< int > buffer;
- tsk::task< void > t1(
- boost::bind(
- barrier_fn,
- boost::ref( b) ) );
+ tsk::task< void > t1( barrier_fn, boost::ref( b) );
tsk::task< void > t2(
- boost::bind(
buffer_fibonacci_fn,
boost::ref( buffer),
- 10) );
+ 10);
tsk::task< void > t3(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 0) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 0);
tsk::async( boost::move( t1), 0, pool);
tsk::async( boost::move( t2), 1, pool);
tsk::async( boost::move( t3), 0, pool);
@@ -603,7 +562,7 @@
}
// check smart scheduling
- void test_case_24()
+ void test_case_25()
{
typedef tsk::static_pool<
tsk::bounded_channel< tsk::smart< int, std::less< int >, tsk::replace_oldest, tsk::take_oldest > >
@@ -618,24 +577,20 @@
boost::barrier b( 2);
std::vector< int > buffer;
tsk::task< void > t1(
- boost::bind(
- barrier_fn,
- boost::ref( b) ) );
+ barrier_fn,
+ boost::ref( b) );
tsk::task< void > t2(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 10) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 10);
tsk::task< void > t3(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 0) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 0);
tsk::task< void > t4(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 1) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 1);
tsk::async( boost::move( t1), 0, pool);
tsk::async( boost::move( t2), 2, pool);
tsk::async( boost::move( t3), 1, pool);
@@ -677,6 +632,7 @@
test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_22, instance) );
test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_23, instance) );
test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_24, instance) );
+ test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_25, instance) );
return test;
}
Modified: sandbox/task/libs/task/test/test_new_thread.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_new_thread.cpp (original)
+++ sandbox/task/libs/task/test/test_new_thread.cpp 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -32,10 +32,7 @@
// check assignment
void test_case_1()
{
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h1;
tsk::handle< int > h2(
tsk::async( boost::move( t), tsk::new_thread() ) );
@@ -47,14 +44,8 @@
// check swap
void test_case_2()
{
- tsk::task< int > t1(
- boost::bind(
- fibonacci_fn,
- 5) );
- tsk::task< int > t2(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t1( fibonacci_fn, 5);
+ tsk::task< int > t2( fibonacci_fn, 10);
tsk::handle< int > h1(
tsk::async( boost::move( t1), tsk::new_thread() ) );
tsk::handle< int > h2(
@@ -87,10 +78,7 @@
// check wait
void test_case_5()
{
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
h.wait();
@@ -103,10 +91,7 @@
// check wait_for
void test_case_6()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 1) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
BOOST_CHECK( h.wait_for( pt::seconds( 3) ) );
@@ -118,10 +103,7 @@
// check wait_for
void test_case_7()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
BOOST_CHECK( ! h.wait_for( pt::seconds( 1) ) );
@@ -133,10 +115,7 @@
// check wait_for
void test_case_8()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 1) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 3) ) );
@@ -148,10 +127,7 @@
// check wait_for
void test_case_9()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
BOOST_CHECK( ! h.wait_until( boost::get_system_time() + pt::seconds( 1) ) );
@@ -163,10 +139,7 @@
// check interrupt
void test_case_10()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
h.interrupt();
@@ -179,10 +152,9 @@
{
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
h.interrupt_and_wait();
@@ -199,10 +171,9 @@
{
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 3) ) );
@@ -217,10 +188,7 @@
// check interrupt_and_wait_for
void test_case_13()
{
- tsk::task< void > t(
- boost::bind(
- non_interrupt_fn,
- 3) );
+ tsk::task< void > t( non_interrupt_fn, 3);
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
BOOST_CHECK( ! h.interrupt_and_wait_for( pt::seconds( 1) ) );
@@ -231,10 +199,9 @@
{
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 3) ) );
@@ -249,10 +216,7 @@
// check interrupt_and_wait_until
void test_case_15()
{
- tsk::task< void > t(
- boost::bind(
- non_interrupt_fn,
- 3) );
+ tsk::task< void > t( non_interrupt_fn, 3);
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::new_thread() ) );
BOOST_CHECK( ! h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 1) ) );
@@ -264,10 +228,7 @@
std::vector< tsk::handle< int > > vec;
for ( int i = 0; i <= 5; ++i)
{
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- i) );
+ tsk::task< int > t( fibonacci_fn, i);
vec.push_back(
tsk::async( boost::move( t), tsk::new_thread() ) );
}
@@ -289,14 +250,8 @@
// check waitfor_any()
void test_case_17()
{
- tsk::task< void > t1(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
- tsk::task< int > t2(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< void > t1( delay_fn, pt::seconds( 3) );
+ tsk::task< int > t2( fibonacci_fn, 10);
tsk::handle< void > h1(
tsk::async( boost::move( t1), tsk::new_thread() ) );
tsk::handle< int > h2(
Modified: sandbox/task/libs/task/test/test_own_thread.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_own_thread.cpp (original)
+++ sandbox/task/libs/task/test/test_own_thread.cpp 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -32,10 +32,7 @@
// check assignment
void test_case_1()
{
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h1;
tsk::handle< int > h2(
tsk::async( boost::move( t), tsk::own_thread() ) );
@@ -47,14 +44,8 @@
// check swap
void test_case_2()
{
- tsk::task< int > t1(
- boost::bind(
- fibonacci_fn,
- 5) );
- tsk::task< int > t2(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t1( fibonacci_fn, 5);
+ tsk::task< int > t2( fibonacci_fn, 10);
tsk::handle< int > h1(
tsk::async( boost::move( t1), tsk::own_thread() ) );
tsk::handle< int > h2(
@@ -102,10 +93,7 @@
// check wait
void test_case_6()
{
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
h.wait();
@@ -118,10 +106,7 @@
// check wait_for
void test_case_7()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 1) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
BOOST_CHECK( h.wait_for( pt::seconds( 2) ) );
@@ -133,10 +118,7 @@
// check wait_for
void test_case_8()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 2) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 2) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
BOOST_CHECK( h.wait_for( pt::seconds( 1) ) );
@@ -148,10 +130,7 @@
// check wait_for
void test_case_9()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 1) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 3) ) );
@@ -163,10 +142,7 @@
// check wait_for
void test_case_10()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 2) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 2) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 1) ) );
@@ -178,10 +154,7 @@
// check interrupt
void test_case_11()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
h.interrupt();
@@ -194,10 +167,9 @@
{
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 3),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 3),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
h.interrupt_and_wait();
@@ -212,10 +184,9 @@
{
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 2) ) );
@@ -230,10 +201,7 @@
// check interrupt_and_wait_for
void test_case_14()
{
- tsk::task< void > t(
- boost::bind(
- non_interrupt_fn,
- 2) );
+ tsk::task< void > t( non_interrupt_fn, 2);
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 1) ) );
@@ -245,10 +213,9 @@
{
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 2) ) );
@@ -263,10 +230,7 @@
// check interrupt_and_wait_until
void test_case_16()
{
- tsk::task< void > t(
- boost::bind(
- non_interrupt_fn,
- 2) );
+ tsk::task< void > t( non_interrupt_fn, 2);
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 1) ) );
@@ -279,10 +243,7 @@
std::vector< tsk::handle< int > > vec;
for ( int i = 0; i <= 5; ++i)
{
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- i) );
+ tsk::task< int > t( fibonacci_fn, i);
vec.push_back(
tsk::async( boost::move( t), tsk::own_thread() ) );
}
@@ -304,14 +265,8 @@
// check waitfor_any()
void test_case_18()
{
- tsk::task< void > t1(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
- tsk::task< int > t2(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< void > t1( delay_fn, pt::seconds( 3) );
+ tsk::task< int > t2( fibonacci_fn, 10);
tsk::handle< void > h1(
tsk::async( boost::move( t1), tsk::own_thread() ) );
tsk::handle< int > h2(
@@ -325,10 +280,7 @@
// check interrupt + wait
void test_case_19()
{
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), tsk::own_thread() ) );
h.interrupt();
Modified: sandbox/task/libs/task/test/test_task.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_task.cpp (original)
+++ sandbox/task/libs/task/test/test_task.cpp 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -32,10 +32,7 @@
// check vaild task
void test_case_1()
{
- tsk::task< int > t1(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t1( fibonacci_fn, 10);
tsk::task< int > t2;
BOOST_CHECK( t1);
BOOST_CHECK( ! t2);
@@ -44,10 +41,7 @@
// check moved task
void test_case_2()
{
- tsk::task< int > t1(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t1( fibonacci_fn, 10);
BOOST_CHECK( t1);
tsk::task< int > t2( boost::move( t1) );
BOOST_CHECK( ! t1);
@@ -58,10 +52,7 @@
// check execute twice
void test_case_3()
{
- tsk::task< int > t1(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t1( fibonacci_fn, 10);
BOOST_CHECK_NO_THROW( t1() );
BOOST_CHECK_THROW( t1(), tsk::task_already_executed);
}
@@ -69,10 +60,7 @@
// check swap
void test_case_4()
{
- tsk::task< int > t1(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t1( fibonacci_fn, 10);
tsk::task< int > t2;
BOOST_CHECK_NO_THROW( t1() );
BOOST_CHECK_THROW( t2(), tsk::task_moved);
Modified: sandbox/task/libs/task/test/test_unbounded_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_unbounded_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_unbounded_pool.cpp 2009-06-20 16:10:03 EDT (Sat, 20 Jun 2009)
@@ -61,10 +61,7 @@
BOOST_CHECK_EQUAL( pool2.idle(), std::size_t( 3) );
BOOST_CHECK_EQUAL( pool2.active(), std::size_t( 0) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), pool2) );
BOOST_CHECK_EQUAL( h.get(), 55);
@@ -76,10 +73,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK_EQUAL( h.get(), 55);
@@ -91,10 +85,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h1;
tsk::handle< int > h2(
tsk::async( boost::move( t), pool) );
@@ -109,14 +100,8 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< int > t1(
- boost::bind(
- fibonacci_fn,
- 5) );
- tsk::task< int > t2(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t1( fibonacci_fn, 5);
+ tsk::task< int > t2( fibonacci_fn, 10);
tsk::handle< int > h1(
tsk::async( boost::move( t1), pool) );
tsk::handle< int > h2(
@@ -146,10 +131,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), pool) );
pool.shutdown();
@@ -176,11 +158,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
- tsk::task< int > t(
- boost::bind(
- boost::bind(
- fibonacci_fn,
- 10) ) );
+ tsk::task< int > t( fibonacci_fn, 10);
pool.shutdown();
BOOST_CHECK( pool.closed() );
BOOST_CHECK_THROW(
@@ -194,10 +172,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 1) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::millisec( 500) ) );
+ tsk::task< void > t( delay_fn, pt::millisec( 500) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
boost::this_thread::sleep( pt::millisec( 250) );
@@ -218,18 +193,9 @@
> pool_type;
pool_type pool( tsk::poolsize( 1) );
boost::barrier b( 2);
- tsk::task< void > t1(
- boost::bind(
- barrier_fn,
- boost::ref( b) ) );
- tsk::task< int > t2(
- boost::bind(
- fibonacci_fn,
- 10) );
- tsk::task< int > t3(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< void > t1( barrier_fn, boost::ref( b) );
+ tsk::task< int > t2( fibonacci_fn, 10);
+ tsk::task< int > t3( fibonacci_fn, 10);
tsk::handle< void > h1(
tsk::async( boost::move( t1), pool) );
boost::this_thread::sleep( pt::millisec( 250) );
@@ -255,10 +221,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
+ tsk::task< int > t( fibonacci_fn, 10);
tsk::handle< int > h(
tsk::async( boost::move( t), pool) );
h.wait();
@@ -274,10 +237,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 1) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( h.wait_for( pt::seconds( 3) ) );
@@ -292,10 +252,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( ! h.wait_for( pt::seconds( 1) ) );
@@ -310,10 +267,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 1) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 1) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( h.wait_until( boost::get_system_time() + pt::seconds( 3) ) );
@@ -328,10 +282,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( ! h.wait_until( boost::get_system_time() + pt::seconds( 1) ) );
@@ -346,10 +297,7 @@
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
+ tsk::task< void > t( delay_fn, pt::seconds( 3) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
h.interrupt();
@@ -357,18 +305,43 @@
BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
}
- // check interrupt_and_wait
+ // check interrupt_all_worker
void test_case_17()
{
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
+ > pool( tsk::poolsize( 5) );
+ tsk::task< void > t1( delay_fn, pt::seconds( 3) );
+ tsk::task< void > t2( delay_fn, pt::seconds( 3) );
+ tsk::task< void > t3( delay_fn, pt::seconds( 3) );
+ tsk::handle< void > h1(
+ tsk::async( boost::move( t1), pool) );
+ tsk::handle< void > h2(
+ tsk::async( boost::move( t2), pool) );
+ tsk::handle< void > h3(
+ tsk::async( boost::move( t3), pool) );
+ boost::this_thread::sleep( pt::millisec( 250) );
+ pool.interrupt_all_worker();
+ BOOST_CHECK( ! h1.interruption_requested() );
+ BOOST_CHECK( ! h2.interruption_requested() );
+ BOOST_CHECK( ! h3.interruption_requested() );
+ BOOST_CHECK_THROW( h1.get(), tsk::task_interrupted);
+ BOOST_CHECK_THROW( h2.get(), tsk::task_interrupted);
+ BOOST_CHECK_THROW( h3.get(), tsk::task_interrupted);
+ BOOST_CHECK_EQUAL( pool.size(), std::size_t( 5) );
+ }
+
+ // check interrupt_and_wait
+ void test_case_18()
+ {
+ tsk::static_pool<
+ tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
h.interrupt_and_wait();
@@ -381,17 +354,16 @@
}
// check interrupt_and_wait_for
- void test_case_18()
+ void test_case_19()
{
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( h.interrupt_and_wait_for( pt::seconds( 3) ) );
@@ -404,32 +376,28 @@
}
// check interrupt_and_wait_for
- void test_case_19()
+ void test_case_20()
{
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< void > t(
- boost::bind(
- non_interrupt_fn,
- 3) );
+ tsk::task< void > t( non_interrupt_fn, 3);
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( ! h.interrupt_and_wait_for( pt::seconds( 1) ) );
}
// check interrupt_and_wait_until
- void test_case_20()
+ void test_case_21()
{
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
bool finished( false);
tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 1),
- boost::ref( finished) ) );
+ interrupt_fn,
+ pt::seconds( 1),
+ boost::ref( finished) );
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 3) ) );
@@ -442,22 +410,19 @@
}
// check interrupt_and_wait_until
- void test_case_21()
+ void test_case_22()
{
tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
> pool( tsk::poolsize( 3) );
- tsk::task< void > t(
- boost::bind(
- non_interrupt_fn,
- 3) );
+ tsk::task< void > t( non_interrupt_fn, 3);
tsk::handle< void > h(
tsk::async( boost::move( t), pool) );
BOOST_CHECK( ! h.interrupt_and_wait_until( boost::get_system_time() + pt::seconds( 1) ) );
}
// check fifo scheduling
- void test_case_22()
+ void test_case_23()
{
typedef tsk::static_pool<
tsk::unbounded_channel< tsk::fifo >
@@ -466,20 +431,15 @@
pool_type pool( tsk::poolsize( 1) );
boost::barrier b( 2);
std::vector< int > buffer;
- tsk::task< void > t1(
- boost::bind(
- barrier_fn,
- boost::ref( b) ) );
+ tsk::task< void > t1( barrier_fn, boost::ref( b) );
tsk::task< void > t2(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 10) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 10);
tsk::task< void > t3(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 0) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 0);
tsk::async( boost::move( t1), pool);
tsk::async( boost::move( t2), pool);
tsk::async( boost::move( t3), pool);
@@ -491,7 +451,7 @@
}
// check priority scheduling
- void test_case_23()
+ void test_case_24()
{
typedef tsk::static_pool<
tsk::unbounded_channel< tsk::priority< int > >
@@ -502,20 +462,15 @@
pool_type pool( tsk::poolsize( 1) );
boost::barrier b( 2);
std::vector< int > buffer;
- tsk::task< void > t1(
- boost::bind(
- barrier_fn,
- boost::ref( b) ) );
+ tsk::task< void > t1( barrier_fn, boost::ref( b) );
tsk::task< void > t2(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 10) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 10) ;
tsk::task< void > t3(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 0) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 0);
tsk::async( boost::move( t1), 0, pool);
tsk::async( boost::move( t2), 1, pool);
tsk::async( boost::move( t3), 0, pool);
@@ -527,7 +482,7 @@
}
// check smart scheduling
- void test_case_24()
+ void test_case_25()
{
typedef tsk::static_pool<
tsk::unbounded_channel< tsk::smart< int, std::less< int >, tsk::replace_oldest, tsk::take_oldest > >
@@ -538,25 +493,19 @@
pool_type pool( tsk::poolsize( 1) );
boost::barrier b( 2);
std::vector< int > buffer;
- tsk::task< void > t1(
- boost::bind(
- barrier_fn,
- boost::ref( b) ) );
+ tsk::task< void > t1( barrier_fn, boost::ref( b) );
tsk::task< void > t2(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 10) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 10);
tsk::task< void > t3(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 0) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 0);
tsk::task< void > t4(
- boost::bind(
- buffer_fibonacci_fn,
- boost::ref( buffer),
- 1) );
+ buffer_fibonacci_fn,
+ boost::ref( buffer),
+ 1);
pool.submit( boost::move( t1), 0);
tsk::async( boost::move( t2), 2, pool);
tsk::async( boost::move( t3), 1, pool);
@@ -598,6 +547,7 @@
test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_22, instance) );
test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_23, instance) );
test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_24, instance) );
+ test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_25, instance) );
return test;
}
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