Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54058 - in sandbox/task: . boost boost/task libs/task/build libs/task/examples libs/task/src libs/task/test
From: oliver.kowalke_at_[hidden]
Date: 2009-06-18 14:15:56


Author: olli
Date: 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
New Revision: 54058
URL: http://svn.boost.org/trac/boost/changeset/54058

Log:
* default_pool() removed because thread_resource_error raised from static pool on FreeBSD

Removed:
   sandbox/task/boost/task/default_pool.hpp
   sandbox/task/libs/task/src/default_pool.cpp
   sandbox/task/libs/task/test/test_default_pool.cpp
Text files modified:
   sandbox/task/boost/task.hpp | 1 -
   sandbox/task/change.log | 1 +
   sandbox/task/libs/task/build/Jamfile.v2 | 2 --
   sandbox/task/libs/task/examples/delay.cpp | 6 +++++-
   sandbox/task/libs/task/examples/interrupt.cpp | 14 +++++++++-----
   sandbox/task/libs/task/examples/pending.cpp | 10 +++++++---
   sandbox/task/libs/task/examples/reschedule_until.cpp | 8 ++++++--
   sandbox/task/libs/task/examples/submit.cpp | 3 ++-
   sandbox/task/libs/task/examples/yield.cpp | 6 ++++--
   sandbox/task/libs/task/test/Jamfile.v2 | 1 -
   10 files changed, 34 insertions(+), 18 deletions(-)

Modified: sandbox/task/boost/task.hpp
==============================================================================
--- sandbox/task/boost/task.hpp (original)
+++ sandbox/task/boost/task.hpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -10,7 +10,6 @@
 #include <boost/task/as_sub_task.hpp>
 #include <boost/task/async.hpp>
 #include <boost/task/bounded_channel.hpp>
-#include <boost/task/default_pool.hpp>
 #include <boost/task/exceptions.hpp>
 #include <boost/task/fifo.hpp>
 #include <boost/task/future.hpp>

Deleted: sandbox/task/boost/task/default_pool.hpp
==============================================================================
--- sandbox/task/boost/task/default_pool.hpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
+++ (empty file)
@@ -1,43 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// 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)
-
-#ifndef BOOST_TASK_DEFAULT_POOL_H
-#define BOOST_TASK_DEFAULT_POOL_H
-
-#include <boost/task/detail/config.hpp>
-#include <boost/task/fifo.hpp>
-#include <boost/task/static_pool.hpp>
-#include <boost/task/unbounded_channel.hpp>
-
-#include <boost/config/abi_prefix.hpp>
-
-#ifdef BOOST_MSVC
-#pragma warning(push)
-#pragma warning(disable:4251 4275)
-#endif
-
-namespace boost { namespace task
-{
-typedef static_pool< unbounded_channel< fifo > > default_pool_t;
-
-namespace detail
-{
-struct static_pool
-{ static BOOST_TASK_DECL default_pool_t instance; };
-}
-
-inline
-default_pool_t & default_pool()
-{ return detail::static_pool::instance; }
-} }
-
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
-
-#include <boost/config/abi_suffix.hpp>
-
-#endif // BOOST_TASK_DEFAULT_POOL_H

Modified: sandbox/task/change.log
==============================================================================
--- sandbox/task/change.log (original)
+++ sandbox/task/change.log 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -8,6 +8,7 @@
   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
 - tests updated
 - examples updated
 - documentation updated

Modified: sandbox/task/libs/task/build/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/build/Jamfile.v2 (original)
+++ sandbox/task/libs/task/build/Jamfile.v2 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -35,7 +35,6 @@
 
 alias task_sources
     : ## win32 sources ##
- default_pool.cpp
         guard.cpp
         interrupter.cpp
         pool_callable.cpp
@@ -53,7 +52,6 @@
 
 alias task_sources
     : ## posix sources ##
- default_pool.cpp
         guard.cpp
         interrupter.cpp
         pool_callable.cpp

Modified: sandbox/task/libs/task/examples/delay.cpp
==============================================================================
--- sandbox/task/libs/task/examples/delay.cpp (original)
+++ sandbox/task/libs/task/examples/delay.cpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -17,6 +17,8 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
+typedef tsk::static_pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
+
 int serial_fib( int n)
 {
         if( n < 2)
@@ -64,6 +66,8 @@
 {
         try
         {
+ pool_type pool( pool_type::bind_to_processors() );
+
                 for ( int i = 0; i < 10; ++i)
                 {
                         tsk::task< void > t(
@@ -72,7 +76,7 @@
                                         i) );
                         tsk::async(
                                 boost::move( t),
- tsk::default_pool() );
+ pool);
                 }
 
                 return EXIT_SUCCESS;

Modified: sandbox/task/libs/task/examples/interrupt.cpp
==============================================================================
--- sandbox/task/libs/task/examples/interrupt.cpp (original)
+++ sandbox/task/libs/task/examples/interrupt.cpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -17,6 +17,8 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
+typedef tsk::static_pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
+
 inline
 int fibonacci_fn( int n)
 {
@@ -42,6 +44,8 @@
 {
         try
         {
+ pool_type pool( pool_type::bind_to_processors() );
+
                 tsk::task< void > t1( long_running_fn);
                 tsk::task< int > t2(
                         boost::bind(
@@ -49,14 +53,14 @@
                                 10) );
                 tsk::async(
                         boost::move( t1),
- tsk::default_pool() );
- std::cout << "poolsize == " << tsk::default_pool().size() << std::endl;
- std::cout << "idle threads == " << tsk::default_pool().idle() << std::endl;
- std::cout << "active threads == " << tsk::default_pool().active() << std::endl;
+ pool);
+ std::cout << "poolsize == " << pool.size() << std::endl;
+ std::cout << "idle threads == " << pool.idle() << std::endl;
+ std::cout << "active threads == " << pool.active() << std::endl;
                 tsk::handle< int > h(
                         tsk::async(
                                 boost::move( t2),
- tsk::default_pool() ) );
+ pool) );
                 h.interrupt();
                 std::cout << h.get() << std::endl;
 

Modified: sandbox/task/libs/task/examples/pending.cpp
==============================================================================
--- sandbox/task/libs/task/examples/pending.cpp (original)
+++ sandbox/task/libs/task/examples/pending.cpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -18,6 +18,8 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
+typedef tsk::static_pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
+
 inline
 int fibonacci_fn( int n)
 {
@@ -43,10 +45,12 @@
 {
         try
         {
+ pool_type pool( pool_type::bind_to_processors() );
+
                 tsk::task< void > t1( long_running_fn);
                 tsk::async(
                         boost::move( t1),
- tsk::default_pool() );
+ pool);
                 tsk::task< int > t2(
                         boost::bind(
                                 fibonacci_fn,
@@ -54,8 +58,8 @@
                 tsk::handle< int > h(
                         tsk::async(
                                 boost::move( t2),
- tsk::default_pool() ) );
- std::cout << "pending tasks == " << tsk::default_pool().pending() << std::endl;
+ pool) );
+ std::cout << "pending tasks == " << pool.pending() << std::endl;
                 std::cout << h.get() << std::endl;
 
                 return EXIT_SUCCESS;

Modified: sandbox/task/libs/task/examples/reschedule_until.cpp
==============================================================================
--- sandbox/task/libs/task/examples/reschedule_until.cpp (original)
+++ sandbox/task/libs/task/examples/reschedule_until.cpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -33,6 +33,8 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
+typedef tsk::static_pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
+
 int serial_fib( int n)
 {
         if( n < 2)
@@ -144,6 +146,8 @@
 # if defined(BOOST_POSIX_API)
         try
         {
+ pool_type pool( pool_type::bind_to_processors() );
+
                 int fd[2];
                 create_sockets( fd);
 
@@ -154,7 +158,7 @@
 
                 tsk::async(
                         boost::move( t1),
- tsk::default_pool() );
+ pool);
 
                 do_write( fd[1], "Hello ");
                 boost::this_thread::sleep( pt::seconds( 1) );
@@ -167,7 +171,7 @@
                                         i) );
                         tsk::async(
                                 boost::move( t),
- tsk::default_pool() );
+ pool);
                 }
 
                 do_write( fd[1], "World!");

Modified: sandbox/task/libs/task/examples/submit.cpp
==============================================================================
--- sandbox/task/libs/task/examples/submit.cpp (original)
+++ sandbox/task/libs/task/examples/submit.cpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -65,7 +65,8 @@
                 tsk::handle< int > h3(
                         tsk::async(
                                 boost::move( t3),
- tsk::default_pool() ) );
+ 2,
+ pool) );
                 tsk::handle< int > h4(
                         tsk::async(
                                 boost::move( t4),

Modified: sandbox/task/libs/task/examples/yield.cpp
==============================================================================
--- sandbox/task/libs/task/examples/yield.cpp (original)
+++ sandbox/task/libs/task/examples/yield.cpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -18,7 +18,7 @@
 namespace pt = boost::posix_time;
 namespace tsk = boost::task;
 
-typedef tsk::default_pool_t pool_type;
+typedef tsk::static_pool< tsk::unbounded_channel< tsk::fifo > > pool_type;
 
 int serial_fib( int n)
 {
@@ -70,6 +70,8 @@
 {
         try
         {
+ pool_type pool( pool_type::bind_to_processors() );
+
                 for ( int i = 0; i < 10; ++i)
                 {
                         tsk::task< void > t(
@@ -78,7 +80,7 @@
                                         i) );
                         tsk::async(
                                 boost::move( t),
- tsk::default_pool() );
+ pool);
                 }
 
                 return EXIT_SUCCESS;

Deleted: sandbox/task/libs/task/src/default_pool.cpp
==============================================================================
--- sandbox/task/libs/task/src/default_pool.cpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
+++ (empty file)
@@ -1,25 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// 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)
-
-#include "boost/task/default_pool.hpp"
-
-#include <boost/thread.hpp>
-
-#include "boost/task/poolsize.hpp"
-
-namespace boost { namespace task
-{
-namespace detail
-{
-namespace
-{
- const poolsize init()
- { return poolsize( thread::hardware_concurrency() ); }
-}
-default_pool_t
-static_pool::instance( init() );
-}
-} }

Modified: sandbox/task/libs/task/test/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/test/Jamfile.v2 (original)
+++ sandbox/task/libs/task/test/Jamfile.v2 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
@@ -29,7 +29,6 @@
     [ task-test test_task ]
     [ task-test test_own_thread ]
     [ task-test test_new_thread ]
- [ task-test test_default_pool ]
     [ task-test test_unbounded_pool ]
     [ task-test test_bounded_pool ]
     ;

Deleted: sandbox/task/libs/task/test/test_default_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_default_pool.cpp 2009-06-18 14:15:54 EDT (Thu, 18 Jun 2009)
+++ (empty file)
@@ -1,205 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// 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)
-
-#include <cstdlib>
-#include <iostream>
-#include <map>
-#include <stdexcept>
-#include <vector>
-
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/function.hpp>
-#include <boost/ref.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/thread.hpp>
-#include <boost/thread/barrier.hpp>
-#include <boost/utility.hpp>
-
-#include <boost/task.hpp>
-
-#include "test_functions.hpp"
-
-namespace pt = boost::posix_time;
-namespace tsk = boost::task;
-
-class test_default_pool
-{
-public:
- // check assignment
- void test_case_1()
- {
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
- tsk::handle< int > h1;
- tsk::handle< int > h2(
- tsk::async( boost::move( t), tsk::default_pool() ) );
- h1 = h2;
- BOOST_CHECK_EQUAL( h1.get(), 55);
- BOOST_CHECK_EQUAL( h2.get(), 55);
- }
-
- // 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::handle< int > h1(
- tsk::async( boost::move( t1), tsk::default_pool() ) );
- tsk::handle< int > h2(
- tsk::async( boost::move( t2), tsk::default_pool() ) );
- BOOST_CHECK_EQUAL( h1.get(), 5);
- BOOST_CHECK_EQUAL( h2.get(), 55);
- BOOST_CHECK_NO_THROW( h1.swap( h2) );
- BOOST_CHECK_EQUAL( h1.get(), 55);
- BOOST_CHECK_EQUAL( h2.get(), 5);
- }
-
- // check runs in pool
- void test_case_3()
- {
- tsk::task< bool > t(
- boost::bind( runs_in_pool_fn) );
- tsk::handle< bool > h(
- tsk::async( boost::move( t), tsk::default_pool() ) );
- BOOST_CHECK_EQUAL( h.get(), true);
- }
-
- // check runtime_error throw inside task
- void test_case_4()
- {
- tsk::task< void > t(
- boost::bind( throwing_fn) );
- tsk::handle< void > h(
- tsk::async( boost::move( t), tsk::default_pool() ) );
- BOOST_CHECK_THROW( h.get(), std::runtime_error);
- }
-
- // check interrupt
- void test_case_5()
- {
- tsk::task< void > t(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
- tsk::handle< void > h(
- tsk::async( boost::move( t), tsk::default_pool() ) );
- h.interrupt();
- BOOST_CHECK( h.interruption_requested() );
- BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
- }
-
- // check interrupt_and_wait
- void test_case_6()
- {
- bool finished( false);
- tsk::task< void > t(
- boost::bind(
- interrupt_fn,
- pt::seconds( 3),
- boost::ref( finished) ) );
- tsk::handle< void > h(
- tsk::async( boost::move( t), tsk::default_pool() ) );
- h.interrupt_and_wait();
- BOOST_CHECK( finished);
- BOOST_CHECK( h.is_ready() );
- BOOST_CHECK( ! h.has_value() );
- BOOST_CHECK( h.has_exception() );
- BOOST_CHECK( h.interruption_requested() );
- BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
- }
-
- // check wait
- void test_case_7()
- {
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- 10) );
- tsk::handle< int > h(
- tsk::async( boost::move( t), tsk::default_pool() ) );
- h.wait();
- BOOST_CHECK( h.is_ready() );
- BOOST_CHECK( h.has_value() );
- BOOST_CHECK( ! h.has_exception() );
- BOOST_CHECK_EQUAL( h.get(), 55);
- }
-
- // check waitfor_all()
- void test_case_8()
- {
- std::vector< tsk::handle< int > > vec;
- for ( int i = 0; i <= 5; ++i)
- {
- tsk::task< int > t(
- boost::bind(
- fibonacci_fn,
- i) );
- vec.push_back(
- tsk::async( boost::move( t), tsk::default_pool() ) );
- }
- tsk::waitfor_all( vec.begin(), vec.end() );
- BOOST_CHECK( vec[0].is_ready() );
- BOOST_CHECK( vec[1].is_ready() );
- BOOST_CHECK( vec[2].is_ready() );
- BOOST_CHECK( vec[3].is_ready() );
- BOOST_CHECK( vec[4].is_ready() );
- BOOST_CHECK( vec[5].is_ready() );
- BOOST_CHECK_EQUAL( vec[0].get(), 0);
- BOOST_CHECK_EQUAL( vec[1].get(), 1);
- BOOST_CHECK_EQUAL( vec[2].get(), 1);
- BOOST_CHECK_EQUAL( vec[3].get(), 2);
- BOOST_CHECK_EQUAL( vec[4].get(), 3);
- BOOST_CHECK_EQUAL( vec[5].get(), 5);
- }
-
- // check waitfor_any()
- void test_case_9()
- {
- tsk::task< void > t1(
- boost::bind(
- delay_fn,
- pt::seconds( 3) ) );
- tsk::task< int > t2(
- boost::bind(
- fibonacci_fn,
- 10) );
- tsk::handle< void > h1(
- tsk::async( boost::move( t1), tsk::default_pool() ) );
- tsk::handle< int > h2(
- tsk::async( boost::move( t2), tsk::default_pool() ) );
- tsk::waitfor_any( h1, h2);
- BOOST_CHECK( ! h1.is_ready() );
- BOOST_CHECK( h2.is_ready() );
- BOOST_CHECK_EQUAL( h2.get(), 55);
- }
-};
-
-boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
-{
- boost::unit_test::test_suite * test( BOOST_TEST_SUITE("Boost.Task: test suite") );
-
- boost::shared_ptr< test_default_pool > instance( new test_default_pool() );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_1, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_2, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_3, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_4, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_5, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_6, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_7, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_8, instance) );
- test->add( BOOST_CLASS_TEST_CASE( & test_default_pool::test_case_9, 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