Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53360 - in sandbox/task: boost boost/task boost/task/detail libs/task/src libs/task/test
From: oliver.kowalke_at_[hidden]
Date: 2009-05-28 16:10:43


Author: olli
Date: 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
New Revision: 53360
URL: http://svn.boost.org/trac/boost/changeset/53360

Log:
* meta-functions added -> check if pool has attributes at compile time
* correction in handle anf interrupter (interrupt_wait_for() and interrupt_and_wait_until())
* tests added

Added:
   sandbox/task/boost/task/detail/meta.hpp (contents, props changed)
   sandbox/task/boost/task/meta.hpp (contents, props changed)
Removed:
   sandbox/task/boost/task/detail/info.hpp
   sandbox/task/boost/task/info.hpp
Text files modified:
   sandbox/task/boost/task.hpp | 2
   sandbox/task/boost/task/exceptions.hpp | 8 +++++
   sandbox/task/boost/task/fifo.hpp | 4 +-
   sandbox/task/boost/task/handle.hpp | 63 ++++++++++++++++++++++++++++++---------
   sandbox/task/boost/task/priority.hpp | 4 +-
   sandbox/task/boost/task/smart.hpp | 4 +-
   sandbox/task/libs/task/src/interrupter.cpp | 2
   sandbox/task/libs/task/test/test_bounded_pool.cpp | 48 +++++++++++++-----------------
   sandbox/task/libs/task/test/test_default_pool.cpp | 21 +-----------
   sandbox/task/libs/task/test/test_new_thread.cpp | 21 +-----------
   sandbox/task/libs/task/test/test_own_thread.cpp | 45 ++++++++++++++-------------
   sandbox/task/libs/task/test/test_unbounded_pool.cpp | 48 +++++++++++++-----------------
   12 files changed, 135 insertions(+), 135 deletions(-)

Modified: sandbox/task/boost/task.hpp
==============================================================================
--- sandbox/task/boost/task.hpp (original)
+++ sandbox/task/boost/task.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -15,7 +15,7 @@
 #include <boost/task/future.hpp>
 #include <boost/task/handle.hpp>
 #include <boost/task/id.hpp>
-#include <boost/task/info.hpp>
+#include <boost/task/meta.hpp>
 #include <boost/task/poolsize.hpp>
 #include <boost/task/priority.hpp>
 #include <boost/task/scanns.hpp>

Deleted: sandbox/task/boost/task/detail/info.hpp
==============================================================================
--- sandbox/task/boost/task/detail/info.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
+++ (empty file)
@@ -1,22 +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_DETAIL_INFO_H
-#define BOOST_TASK_DETAIL_INFO_H
-
-namespace boost { namespace task
-{
-namespace detail
-{
-struct has_priority
-{};
-
-struct has_no_priority
-{};
-} } }
-
-#endif // BOOST_TASK_DETAIL_INFO_H
-

Added: sandbox/task/boost/task/detail/meta.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/detail/meta.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -0,0 +1,22 @@
+
+// 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_DETAIL_INFO_H
+#define BOOST_TASK_DETAIL_INFO_H
+
+namespace boost { namespace task
+{
+namespace detail
+{
+struct has_attribute
+{};
+
+struct has_no_attribute
+{};
+} } }
+
+#endif // BOOST_TASK_DETAIL_INFO_H
+

Modified: sandbox/task/boost/task/exceptions.hpp
==============================================================================
--- sandbox/task/boost/task/exceptions.hpp (original)
+++ sandbox/task/boost/task/exceptions.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -44,6 +44,14 @@
         {}
 };
 
+class task_uninitialized : public std::logic_error
+{
+public:
+ task_uninitialized()
+ : std::logic_error("task uninitialized")
+ {}
+};
+
 class task_already_executed : public std::logic_error
 {
 public:

Modified: sandbox/task/boost/task/fifo.hpp
==============================================================================
--- sandbox/task/boost/task/fifo.hpp (original)
+++ sandbox/task/boost/task/fifo.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -11,13 +11,13 @@
 #include <list>
 
 #include <boost/task/detail/pool_callable.hpp>
-#include <boost/task/detail/info.hpp>
+#include <boost/task/detail/meta.hpp>
 
 namespace boost { namespace task
 {
 struct fifo
 {
- typedef detail::has_no_priority priority_tag_type;
+ typedef detail::has_no_attribute attribute_tag_type;
 
         class impl
         {

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -57,7 +57,7 @@
 
         shared_future< R > fut_;
         detail::interrupter intr_;
- id id_;
+ id id_;
 
         handle(
                 id const& id__,
@@ -97,6 +97,8 @@
         {
                 try
                 { return fut_.get(); }
+ catch ( future_uninitialized const&)
+ { throw task_uninitialized(); }
                 catch ( broken_promise const&)
                 { throw broken_task(); }
                 catch ( promise_already_satisfied const&)
@@ -113,14 +115,29 @@
         { return fut_.has_exception(); }
 
         void wait() const
- { fut_.wait(); }
+ {
+ try
+ { fut_.wait(); }
+ catch ( future_uninitialized const&)
+ { throw task_uninitialized(); }
+ }
 
     template< typename Duration >
     bool wait_for( Duration const& rel_time) const
- { return fut_.timed_wait( rel_time); }
+ {
+ try
+ { return fut_.timed_wait( rel_time); }
+ catch ( future_uninitialized const&)
+ { throw task_uninitialized(); }
+ }
 
     bool wait_until( system_time const& abs_time) const
- { return fut_.timed_wait_until( abs_time); }
+ {
+ try
+ { return fut_.timed_wait_until( abs_time); }
+ catch ( future_uninitialized const&)
+ { throw task_uninitialized(); }
+ }
 
         void swap( handle< R > & other)
         {
@@ -174,7 +191,6 @@
         id_( id__)
         {}
 
-
 public:
         handle()
         : fut_(), intr_(), id_()
@@ -189,12 +205,12 @@
         void interrupt_and_wait()
         { intr_.interrupt_and_wait(); }
 
- void interrupt_and_wait( system_time const& abs_time)
- { intr_.interrupt_and_wait( abs_time); }
+ void interrupt_and_wait_until( system_time const& abs_time)
+ { intr_.interrupt_and_wait_until( abs_time); }
 
         template< typename Duration >
- void interrupt_and_wait( Duration const& rel_time)
- { intr_.interrupt_and_wait( rel_time); }
+ void interrupt_and_wait_for( Duration const& rel_time)
+ { intr_.interrupt_and_wait_for( rel_time); }
 
         bool interruption_requested()
         { return intr_.interruption_requested(); }
@@ -203,6 +219,8 @@
         {
                 try
                 { fut_.get(); }
+ catch ( future_uninitialized const&)
+ { throw task_uninitialized(); }
                 catch ( broken_promise const&)
                 { throw broken_task(); }
                 catch ( promise_already_satisfied const&)
@@ -219,14 +237,29 @@
         { return fut_.has_exception(); }
 
         void wait() const
- { fut_.wait(); }
+ {
+ try
+ { fut_.wait(); }
+ catch ( future_uninitialized const&)
+ { throw task_uninitialized(); }
+ }
 
- void interrupt_and_wait_until( system_time const& abs_time)
- { intr_.interrupt_and_wait_until( abs_time); }
+ template< typename Duration >
+ bool wait_for( Duration const& rel_time) const
+ {
+ try
+ { return fut_.timed_wait( rel_time); }
+ catch ( future_uninitialized const&)
+ { throw task_uninitialized(); }
+ }
 
- template< typename Duration >
- void interrupt_and_wait_for( Duration const& rel_time)
- { intr_.interrupt_and_wait_for( rel_time); }
+ bool wait_until( system_time const& abs_time) const
+ {
+ try
+ { return fut_.timed_wait_until( abs_time); }
+ catch ( future_uninitialized const&)
+ { throw task_uninitialized(); }
+ }
 
         void swap( handle< void > & other)
         {

Deleted: sandbox/task/boost/task/info.hpp
==============================================================================
--- sandbox/task/boost/task/info.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
+++ (empty file)
@@ -1,22 +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_DETAIL_INFO_H
-#define BOOST_TASK_DETAIL_INFO_H
-
-namespace boost { namespace task
-{
-namespace detail
-{
-struct has_priority
-{};
-
-struct has_no_priority
-{};
-} } }
-
-#endif // BOOST_TASK_DETAIL_INFO_H
-

Added: sandbox/task/boost/task/meta.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/meta.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -0,0 +1,34 @@
+
+// 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_META_H
+#define BOOST_TASK_META_H
+
+#include <boost/mpl/bool.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/task/detail/meta.hpp>
+
+namespace boost { namespace task
+{
+template< typename Pool >
+struct has_attribute : public mpl::bool_<
+ is_same<
+ detail::has_attribute,
+ typename Pool::scheduler_type::attribute_tag_type
+ >::value
+>
+{};
+
+template< typename Pool >
+struct attribute_type
+{
+ typedef typename Pool::scheduler_type::attribute_type type;
+};
+} }
+
+#endif // BOOST_TASK_META_H
+

Modified: sandbox/task/boost/task/priority.hpp
==============================================================================
--- sandbox/task/boost/task/priority.hpp (original)
+++ sandbox/task/boost/task/priority.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -16,7 +16,7 @@
 #include <boost/multi_index/ordered_index.hpp>
 
 #include <boost/task/detail/pool_callable.hpp>
-#include <boost/task/detail/info.hpp>
+#include <boost/task/detail/meta.hpp>
 
 namespace boost { namespace task
 {
@@ -26,7 +26,7 @@
>
 struct priority
 {
- typedef detail::has_priority priority_tag_type;
+ typedef detail::has_attribute attribute_tag_type;
         typedef Attr attribute_type;
 
         class impl

Modified: sandbox/task/boost/task/smart.hpp
==============================================================================
--- sandbox/task/boost/task/smart.hpp (original)
+++ sandbox/task/boost/task/smart.hpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -15,7 +15,7 @@
 #include <boost/multi_index/ordered_index.hpp>
 
 #include <boost/task/detail/pool_callable.hpp>
-#include <boost/task/detail/info.hpp>
+#include <boost/task/detail/meta.hpp>
 
 namespace boost { namespace task
 {
@@ -27,7 +27,7 @@
>
 struct smart
 {
- typedef detail::has_priority priority_tag_type;
+ typedef detail::has_attribute attribute_tag_type;
         typedef Attr attribute_type;
 
         class impl

Modified: sandbox/task/libs/task/src/interrupter.cpp
==============================================================================
--- sandbox/task/libs/task/src/interrupter.cpp (original)
+++ sandbox/task/libs/task/src/interrupter.cpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -116,7 +116,7 @@
 
 void
 interrupter::interrupt_and_wait_until( system_time const& abs_time)
-{ impl_->interrupt_and_wait( abs_time); }
+{ impl_->interrupt_and_wait_until( abs_time); }
 
 bool
 interrupter::interruption_requested()

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-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -17,6 +17,7 @@
 #include <boost/test/unit_test.hpp>
 #include <boost/thread.hpp>
 #include <boost/thread/barrier.hpp>
+#include <boost/type_traits/is_same.hpp>
 #include <boost/utility.hpp>
 
 #include <boost/task.hpp>
@@ -138,12 +139,7 @@
                                 tsk::make_task(
                                         throwing_fn) ) );
                 pool.shutdown();
- bool thrown( false);
- try
- { h.get(); }
- catch ( std::runtime_error const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
         // check shutdown with task_rejected exception
@@ -157,19 +153,14 @@
                         tsk::low_watermark( 10) );
                 pool.shutdown();
                 BOOST_CHECK( pool.closed() );
- bool thrown( false);
- try
- {
+ BOOST_CHECK_THROW(
                         tsk::async(
                                 pool,
                                 tsk::make_task(
                                         boost::bind(
                                                 fibonacci_fn,
- 10) ) );
- }
- catch ( tsk::task_rejected const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ 10) ) ),
+ tsk::task_rejected);
         }
 
         // check shutdown_now with thread_interrupted exception
@@ -194,12 +185,7 @@
                 BOOST_CHECK_EQUAL( pool.size(), std::size_t( 1) );
                 BOOST_CHECK_EQUAL( pool.idle(), std::size_t( 1) );
                 BOOST_CHECK_EQUAL( pool.active(), std::size_t( 0) );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check pending
@@ -279,12 +265,7 @@
                 pool.shutdown();
                 BOOST_CHECK_EQUAL( buffer[0], 0);
                 BOOST_CHECK_EQUAL( buffer.size(), std::size_t( 1) );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check fifo scheduling
@@ -293,6 +274,7 @@
                 typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::fifo >
> pool_type;
+ BOOST_CHECK( ! tsk::has_attribute< pool_type >::value);
                 pool_type pool(
                         tsk::poolsize( 1),
                         tsk::high_watermark( 10),
@@ -329,6 +311,12 @@
                 typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::priority< int > >
> pool_type;
+ BOOST_CHECK( tsk::has_attribute< pool_type >::value);
+ BOOST_CHECK(
+ boost::is_same<
+ tsk::attribute_type< pool_type >::type,
+ int
+ >::value);
                 pool_type pool(
                         tsk::poolsize( 1),
                         tsk::high_watermark( 10),
@@ -368,6 +356,12 @@
                 typedef tsk::static_pool<
                         tsk::bounded_channel< tsk::smart< int, std::less< int >, tsk::replace_oldest, tsk::take_oldest > >
> pool_type;
+ BOOST_CHECK( tsk::has_attribute< pool_type >::value);
+ BOOST_CHECK(
+ boost::is_same<
+ tsk::attribute_type< pool_type >::type,
+ int
+ >::value);
                 pool_type pool(
                         tsk::poolsize( 1),
                         tsk::high_watermark( 10),
@@ -417,7 +411,7 @@
         test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_1, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_2, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_3, instance) );
- //test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_4, instance) );
+ test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_4, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_5, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_6, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_bounded_pool::test_case_7, instance) );

Modified: sandbox/task/libs/task/test/test_default_pool.cpp
==============================================================================
--- sandbox/task/libs/task/test/test_default_pool.cpp (original)
+++ sandbox/task/libs/task/test/test_default_pool.cpp 2009-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -82,12 +82,7 @@
                                 tsk::default_pool(),
                                 tsk::make_task(
                                         throwing_fn) ) );
- bool thrown( false);
- try
- { h.get(); }
- catch ( std::runtime_error const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
         // check interrupt
@@ -101,12 +96,7 @@
                                         pt::seconds( 3) ) ) );
                 h.interrupt();
                 BOOST_CHECK( h.interruption_requested() );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check interrupt_and_wait
@@ -124,12 +114,7 @@
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.interruption_requested() );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check waitfor_all()

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-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -82,12 +82,7 @@
                                 tsk::new_thread(),
                                 tsk::make_task(
                                         throwing_fn) ) );
- bool thrown( false);
- try
- { h.get(); }
- catch ( std::runtime_error const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
         // check interrupt
@@ -101,12 +96,7 @@
                                         pt::seconds( 3) ) ) );
                 h.interrupt();
                 BOOST_CHECK( h.interruption_requested() );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check interrupt_and_wait
@@ -124,12 +114,7 @@
                 BOOST_CHECK( finished);
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.interruption_requested() );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check waitfor_all()

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-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -82,17 +82,27 @@
                                 tsk::own_thread(),
                                 tsk::make_task(
                                         throwing_fn) ) );
- bool thrown( false);
- try
- { h.get(); }
- catch ( std::runtime_error const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
- // check interrupt
+ // check task_uninitialized
         void test_case_5()
         {
+ tsk::handle< int > h;
+ BOOST_CHECK_THROW( h.get(), tsk::task_uninitialized);
+ BOOST_CHECK_THROW( h.wait(), tsk::task_uninitialized);
+ BOOST_CHECK_THROW( h.wait_for( pt::seconds( 1) ), tsk::task_uninitialized);
+ BOOST_CHECK_THROW(
+ h.wait_until( boost::get_system_time() + pt::seconds( 1) ),
+ tsk::task_uninitialized);
+ BOOST_CHECK( ! h.is_ready() );
+ BOOST_CHECK( ! h.has_value() );
+ BOOST_CHECK( ! h.has_exception() );
+ }
+
+ // check interrupt
+ void test_case_6()
+ {
                 tsk::handle< void > h(
                         tsk::async(
                                 tsk::own_thread(),
@@ -101,16 +111,11 @@
                                         pt::seconds( 3) ) ) );
                 h.interrupt();
                 BOOST_CHECK( h.interruption_requested() );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( ! thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check interrupt_and_wait
- void test_case_6()
+ void test_case_7()
         {
                 bool finished( false);
                 tsk::handle< void > h(
@@ -124,16 +129,11 @@
                 BOOST_CHECK( ! finished);
                 BOOST_CHECK( h.is_ready() );
                 BOOST_CHECK( h.interruption_requested() );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( ! thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check waitfor_all()
- void test_case_7()
+ void test_case_8()
         {
                 std::vector< tsk::handle< int > > vec;
                 for ( int i = 0; i <= 5; ++i)
@@ -159,7 +159,7 @@
         }
 
         // check waitfor_any()
- void test_case_8()
+ void test_case_9()
         {
                 tsk::handle< void > h1(
                         tsk::async(
@@ -193,6 +193,7 @@
         test->add( BOOST_CLASS_TEST_CASE( & test_own_thread::test_case_6, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_own_thread::test_case_7, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_own_thread::test_case_8, instance) );
+ test->add( BOOST_CLASS_TEST_CASE( & test_own_thread::test_case_9, instance) );
 
         return test;
 }

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-05-28 16:10:41 EDT (Thu, 28 May 2009)
@@ -17,6 +17,7 @@
 #include <boost/test/unit_test.hpp>
 #include <boost/thread.hpp>
 #include <boost/thread/barrier.hpp>
+#include <boost/type_traits/is_same.hpp>
 #include <boost/utility.hpp>
 
 #include <boost/task.hpp>
@@ -120,12 +121,7 @@
                                 tsk::make_task(
                                         throwing_fn) ) );
                 pool.shutdown();
- bool thrown( false);
- try
- { h.get(); }
- catch ( std::runtime_error const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), std::runtime_error);
         }
 
         // check shutdown with task_rejected exception
@@ -136,19 +132,14 @@
> pool( tsk::poolsize( 1) );
                 pool.shutdown();
                 BOOST_CHECK( pool.closed() );
- bool thrown( false);
- try
- {
+ BOOST_CHECK_THROW(
                         tsk::async(
                                 pool,
                                 tsk::make_task(
                                         boost::bind(
                                                 fibonacci_fn,
- 10) ) );
- }
- catch ( tsk::task_rejected const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ 10) ) ),
+ tsk::task_rejected);
         }
 
         // check shutdown_now with thread_interrupted exception
@@ -170,12 +161,7 @@
                 BOOST_CHECK_EQUAL( pool.size(), std::size_t( 1) );
                 BOOST_CHECK_EQUAL( pool.idle(), std::size_t( 1) );
                 BOOST_CHECK_EQUAL( pool.active(), std::size_t( 0) );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check pending
@@ -248,12 +234,7 @@
                 pool.shutdown();
                 BOOST_CHECK_EQUAL( buffer[0], 0);
                 BOOST_CHECK_EQUAL( buffer.size(), std::size_t( 1) );
- bool thrown( false);
- try
- { h.get(); }
- catch ( tsk::task_interrupted const&)
- { thrown = true; }
- BOOST_CHECK( thrown);
+ BOOST_CHECK_THROW( h.get(), tsk::task_interrupted);
         }
 
         // check fifo scheduling
@@ -262,6 +243,7 @@
                 typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::fifo >
> pool_type;
+ BOOST_CHECK( ! tsk::has_attribute< pool_type >::value);
                 pool_type pool( tsk::poolsize( 1) );
                 boost::barrier b( 2);
                 tsk::async(
@@ -295,6 +277,12 @@
                 typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::priority< int > >
> pool_type;
+ BOOST_CHECK( tsk::has_attribute< pool_type >::value);
+ BOOST_CHECK(
+ boost::is_same<
+ tsk::attribute_type< pool_type >::type,
+ int
+ >::value);
                 pool_type pool( tsk::poolsize( 1) );
                 boost::barrier b( 2);
                 tsk::async(
@@ -331,6 +319,12 @@
                 typedef tsk::static_pool<
                         tsk::unbounded_channel< tsk::smart< int, std::less< int >, tsk::replace_oldest, tsk::take_oldest > >
> pool_type;
+ BOOST_CHECK( tsk::has_attribute< pool_type >::value);
+ BOOST_CHECK(
+ boost::is_same<
+ tsk::attribute_type< pool_type >::type,
+ int
+ >::value);
                 pool_type pool( tsk::poolsize( 1) );
                 boost::barrier b( 2);
                 pool.submit(
@@ -376,7 +370,7 @@
         test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_1, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_2, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_3, instance) );
-// test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_4, instance) );
+ test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_4, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_5, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_6, instance) );
         test->add( BOOST_CLASS_TEST_CASE( & test_unbounded_pool::test_case_7, instance) );


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