|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55276 - in sandbox/task: . boost/task libs/task/doc libs/task/examples
From: oliver.kowalke_at_[hidden]
Date: 2009-07-30 14:45:07
Author: olli
Date: 2009-07-30 01:05:10 EDT (Thu, 30 Jul 2009)
New Revision: 55276
URL: http://svn.boost.org/trac/boost/changeset/55276
Log:
* reschedue_until(), dely(), yield() removed
Removed:
sandbox/task/libs/task/examples/delay.cpp
sandbox/task/libs/task/examples/yield.cpp
Text files modified:
sandbox/task/boost/task/utility.hpp | 78 ++-------------------------------------
sandbox/task/change.log | 8 ++++
sandbox/task/libs/task/doc/ref_utility.qbk | 54 ---------------------------
sandbox/task/libs/task/doc/utilities.qbk | 16 --------
sandbox/task/libs/task/examples/Jamfile.v2 | 2 -
5 files changed, 12 insertions(+), 146 deletions(-)
Modified: sandbox/task/boost/task/utility.hpp
==============================================================================
--- sandbox/task/boost/task/utility.hpp (original)
+++ sandbox/task/boost/task/utility.hpp 2009-07-30 01:05:10 EDT (Thu, 30 Jul 2009)
@@ -17,43 +17,6 @@
namespace boost { namespace this_task
{
-namespace detail
-{
-struct time_reached
-{
- system_time abs_time;
-
- time_reached( system_time & abs_time_)
- : abs_time( abs_time_)
- {}
-
- bool operator()()
- { return get_system_time() >= abs_time; }
-};
-
-class once_false
-{
-private:
- bool result_;
-
-public:
- once_false()
- : result_( false)
- {}
-
- bool operator()()
- {
- if ( ! result_)
- {
- result_ = true;
- return false;
- }
- else
- return true;
- }
-};
-}
-
template< typename Pool >
Pool & get_pool()
{
@@ -67,52 +30,19 @@
{ return task::detail::worker::tss_get() != 0; }
inline
-thread::id worker_id()
+bool block()
{
task::detail::worker * w( task::detail::worker::tss_get() );
BOOST_ASSERT( w);
- return w->get_id();
+ return w->block();
}
inline
-void delay( system_time abs_time)
-{
- if ( runs_in_pool() )
- {
- detail::time_reached t( abs_time);
- task::detail::worker * w( task::detail::worker::tss_get() );
- BOOST_ASSERT( w);
- w->reschedule_until( t);
- }
- else
- this_thread::sleep( abs_time);
-}
-
-template< typename Duration >
-void delay( Duration const& rel_time)
-{ delay( get_system_time() + rel_time); }
-
-inline
-void yield()
-{
- if ( runs_in_pool() )
- {
- detail::once_false t;
- task::detail::worker * w( task::detail::worker::tss_get() );
- BOOST_ASSERT( w);
- w->reschedule_until( t);
- }
- else
- this_thread::yield();
-}
-
-inline
-void interrupt()
+thread::id worker_id()
{
task::detail::worker * w( task::detail::worker::tss_get() );
BOOST_ASSERT( w);
- w->interrupt();
- this_thread::interruption_point();
+ return w->get_id();
}
}}
Modified: sandbox/task/change.log
==============================================================================
--- sandbox/task/change.log (original)
+++ sandbox/task/change.log 2009-07-30 01:05:10 EDT (Thu, 30 Jul 2009)
@@ -1,3 +1,11 @@
+* boost.task-0.3.0:
+-------------------
+- worker creates fiber
+- worker with new function block()
+- this::reschedule_until(), this_task::yield(), this_task:delay() removed
+- pool_base catches thread_interrupted exception if worker gets interrupted while sleeping
+
+
* boost.task-0.2.2:
-------------------
- allow user-defined execution policies
Modified: sandbox/task/libs/task/doc/ref_utility.qbk
==============================================================================
--- sandbox/task/libs/task/doc/ref_utility.qbk (original)
+++ sandbox/task/libs/task/doc/ref_utility.qbk 2009-07-30 01:05:10 EDT (Thu, 30 Jul 2009)
@@ -57,57 +57,3 @@
[endsect]
-
-[section:delay Non-member function `delay()`]
-
-``
- #include <boost/task/utility.hpp>
-
- void delay( system_time abs_time)
-
- template< typename Duration >
- void delay( Duration const& rel_time)
-``
-
-[variablelist
-[[Effects:] [delays the execution of the current task so that the worker-thread can process another task in the meantime]]
-[[Throws:] [nothing]]
-[[Note:] [this function resides in namespace `boost::this_task`]]
-]
-
-[endsect]
-
-
-[section:yield Non-member function `yield()`]
-
-``
- #include <boost/task/utility.hpp>
-
- void yield()
-``
-
-[variablelist
-[[Effects:] [yields the current task so that the worker-threadcan process another task in the meantime]]
-[[Throws:] [nothing]]
-[[Note:] [this function resides in namespace `boost::this_task`]]
-]
-
-[endsect]
-
-
-[section:interrupt Non-member function `interrupt()`]
-
-``
- #include <boost/task/utility.hpp>
-
- void interrupt()
-``
-
-[variablelist
-[[Effects:] [task can request interruption for itself]]
-[[Throws:] [nothing]]
-[[Note:] [this function resides in namespace `boost::this_task`]]
-]
-
-[endsect]
-
Modified: sandbox/task/libs/task/doc/utilities.qbk
==============================================================================
--- sandbox/task/libs/task/doc/utilities.qbk (original)
+++ sandbox/task/libs/task/doc/utilities.qbk 2009-07-30 01:05:10 EDT (Thu, 30 Jul 2009)
@@ -28,20 +28,4 @@
__fn_worker_id__ returns the __thread_id__ of the __worker_thread__ executing the current __task__.
-[heading delay]
-
-The execution of a __task__ can be delayed for a time-duration or until a specific time-point with __fn_delay__.
-
-
-[heading yield]
-
-If a __task__ detects that it would bould block it can yield itself with __fn_yield__ so that the __worker_thread__ can execute
-another __task__ in the meantime.
-
-
-[heading interrupt]
-
-A __task__ can interrupt itself via __fn_tt_interrupt__.
-
-
[endsect]
Modified: sandbox/task/libs/task/examples/Jamfile.v2
==============================================================================
--- sandbox/task/libs/task/examples/Jamfile.v2 (original)
+++ sandbox/task/libs/task/examples/Jamfile.v2 2009-07-30 01:05:10 EDT (Thu, 30 Jul 2009)
@@ -25,7 +25,6 @@
;
exe bind_to_processors : bind_to_processors.cpp ;
-exe delay : delay.cpp ;
exe fork_join : fork_join.cpp ;
exe interrupt : interrupt.cpp ;
exe pending : pending.cpp ;
@@ -33,4 +32,3 @@
exe shutdonw_now : shutdown_now.cpp ;
exe smart : smart.cpp ;
exe submit : submit.cpp ;
-exe yield : yield.cpp ;
Deleted: sandbox/task/libs/task/examples/delay.cpp
==============================================================================
--- sandbox/task/libs/task/examples/delay.cpp 2009-07-30 01:05:10 EDT (Thu, 30 Jul 2009)
+++ (empty file)
@@ -1,86 +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 <iostream>
-#include <cstdlib>
-#include <stdexcept>
-#include <vector>
-
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-
-#include "boost/task.hpp"
-
-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)
- return n;
- else
- return serial_fib( n - 1) + serial_fib( n - 2);
-}
-
-int parallel_fib_( int n, int cutof)
-{
- if ( n < cutof)
- {
- if ( n == 0)
- boost::this_task::delay( pt::seconds( 2) );
- return serial_fib( n);
- }
- else
- {
- BOOST_ASSERT( boost::this_task::runs_in_pool() );
- tsk::handle< int > h1(
- tsk::async(
- tsk::make_task(
- parallel_fib_,
- n - 1,
- cutof),
- tsk::as_sub_task() ) );
- tsk::handle< int > h2(
- tsk::async(
- tsk::make_task(
- parallel_fib_,
- n - 2,
- cutof),
- tsk::as_sub_task() ) );
- return h1.get() + h2.get();
- }
-}
-
-void parallel_fib( int n)
-{
- int result = parallel_fib_( n, 5);
- printf("fibonnaci(%d) == %d\n", n, result);
-}
-
-int main( int argc, char *argv[])
-{
- try
- {
- pool_type pool( tsk::poolsize( 5) );
-
- for ( int i = 0; i < 10; ++i)
- tsk::async(
- tsk::make_task(
- parallel_fib,
- i),
- pool);
-
- return EXIT_SUCCESS;
- }
- catch ( std::exception const& e)
- { std::cerr << "exception: " << e.what() << std::endl; }
- catch ( ... )
- { std::cerr << "unhandled" << std::endl; }
-
- return EXIT_FAILURE;
-}
Deleted: sandbox/task/libs/task/examples/yield.cpp
==============================================================================
--- sandbox/task/libs/task/examples/yield.cpp 2009-07-30 01:05:10 EDT (Thu, 30 Jul 2009)
+++ (empty file)
@@ -1,89 +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 <iostream>
-#include <cstdlib>
-#include <stdexcept>
-#include <vector>
-
-#include <boost/assert.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-
-#include "boost/task.hpp"
-
-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)
- return n;
- else
- return serial_fib( n - 1) + serial_fib( n - 2);
-}
-
-int parallel_fib_( int n, int cutof)
-{
- if ( n == 4)
- boost::this_task::yield();
-
- if ( n < cutof)
- {
- if ( n == 0)
- boost::this_task::delay( pt::seconds( 2) );
- return serial_fib( n);
- }
- else
- {
- BOOST_ASSERT( boost::this_task::runs_in_pool() );
- tsk::task< int > t1(
- parallel_fib_,
- n - 1,
- cutof);
- tsk::task< int > t2(
- parallel_fib_,
- n - 2,
- cutof);
- tsk::handle< int > h1(
- tsk::async( boost::move( t1), tsk::as_sub_task() ) );
- tsk::handle< int > h2(
- tsk::async( boost::move( t2), tsk::as_sub_task() ) );
- return h1.get() + h2.get();
- }
-}
-
-void parallel_fib( int n)
-{
- int result = parallel_fib_( n, 5);
- printf("fibonnaci(%d) == %d\n", n, result);
-}
-
-int main( int argc, char *argv[])
-{
- try
- {
- pool_type pool( tsk::poolsize( 3) );
-
- for ( int i = 0; i < 10; ++i)
- {
- tsk::task< void > t( parallel_fib, i);
- tsk::async(
- boost::move( t),
- pool);
- }
-
- return EXIT_SUCCESS;
- }
- catch ( std::exception const& e)
- { std::cerr << "exception: " << e.what() << std::endl; }
- catch ( ... )
- { std::cerr << "unhandled" << std::endl; }
-
- return EXIT_FAILURE;
-}
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