Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55242 - in sandbox/task: boost/task boost/task/detail libs/task/doc libs/task/examples libs/task/src
From: oliver.kowalke_at_[hidden]
Date: 2009-07-30 14:44:24


Author: olli
Date: 2009-07-28 16:02:09 EDT (Tue, 28 Jul 2009)
New Revision: 55242
URL: http://svn.boost.org/trac/boost/changeset/55242

Log:
* remove of this::reschedule_until
* worker::block() added

Removed:
   sandbox/task/libs/task/examples/reschedule_until.cpp
Text files modified:
   sandbox/task/boost/task/detail/worker.hpp | 8 +++++++-
   sandbox/task/boost/task/utility.hpp | 16 ++++++----------
   sandbox/task/libs/task/doc/acknowledgements.qbk | 2 +-
   sandbox/task/libs/task/doc/ref_utility.qbk | 18 ------------------
   sandbox/task/libs/task/doc/utilities.qbk | 7 -------
   sandbox/task/libs/task/examples/Jamfile.v2 | 1 -
   sandbox/task/libs/task/src/worker.cpp | 12 ++++++++----
   7 files changed, 22 insertions(+), 42 deletions(-)

Modified: sandbox/task/boost/task/detail/worker.hpp
==============================================================================
--- sandbox/task/boost/task/detail/worker.hpp (original)
+++ sandbox/task/boost/task/detail/worker.hpp 2009-07-28 16:02:09 EDT (Tue, 28 Jul 2009)
@@ -56,9 +56,11 @@
 
         virtual void signal_shutdown_now() = 0;
 
+ virtual void run() = 0;
+
         virtual void reschedule_until( function< bool() > const&) = 0;
 
- virtual void run() = 0;
+ virtual bool block() = 0;
 };
 
 template<
@@ -286,6 +288,9 @@
                         }
                 }
         }
+
+ bool block()
+ { return ! shutdown_(); }
 };
 
 class BOOST_TASK_DECL worker
@@ -333,6 +338,7 @@
 
         void run();
         void reschedule_until( function< bool() > const&);
+ bool block();
 
         static worker * tss_get();
 };

Modified: sandbox/task/boost/task/utility.hpp
==============================================================================
--- sandbox/task/boost/task/utility.hpp (original)
+++ sandbox/task/boost/task/utility.hpp 2009-07-28 16:02:09 EDT (Tue, 28 Jul 2009)
@@ -54,14 +54,6 @@
 };
 }
 
-template< typename Pred >
-void reschedule_until( Pred const& pred)
-{
- task::detail::worker * w( task::detail::worker::tss_get() );
- BOOST_ASSERT( w);
- w->reschedule_until( pred);
-}
-
 template< typename Pool >
 Pool & get_pool()
 {
@@ -88,7 +80,9 @@
         if ( runs_in_pool() )
         {
                 detail::time_reached t( abs_time);
- reschedule_until( t);
+ task::detail::worker * w( task::detail::worker::tss_get() );
+ BOOST_ASSERT( w);
+ w->reschedule_until( t);
         }
         else
                 this_thread::sleep( abs_time);
@@ -104,7 +98,9 @@
         if ( runs_in_pool() )
         {
                 detail::once_false t;
- reschedule_until( t);
+ task::detail::worker * w( task::detail::worker::tss_get() );
+ BOOST_ASSERT( w);
+ w->reschedule_until( t);
         }
         else
                 this_thread::yield();

Modified: sandbox/task/libs/task/doc/acknowledgements.qbk
==============================================================================
--- sandbox/task/libs/task/doc/acknowledgements.qbk (original)
+++ sandbox/task/libs/task/doc/acknowledgements.qbk 2009-07-28 16:02:09 EDT (Tue, 28 Jul 2009)
@@ -8,7 +8,7 @@
 
 [section:acknowledgements Appendix B: Acknowledgments]
 
-I'd like to thank Vicente J. Botet Escriba for his comments and contributions (this_task::reschedule_until, this_task::delay, this_task::yield) as well Anthony Williams and Braddock Gaskill for their future libraries.
+I'd like to thank Vicente J. Botet Escriba for his comments and contributions (this_task::delay, this_task::yield) as well Anthony Williams and Braddock Gaskill for their future libraries.
 
 
 [endsect]

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-28 16:02:09 EDT (Tue, 28 Jul 2009)
@@ -6,24 +6,6 @@
 ]
 
 
-[section:reschedule_until Non-member function `reschedule_until()`]
-
-``
- #include <boost/task/utility.hpp>
-
- template< typename Pred >
- void reschedule_until( Pred const&)
-``
-
-[variablelist
-[[Effects:] [reschedules current task until passed callable predicate becomes ready]]
-[[Throws:] [`boost::thread_interrupted`,`boost::system::system_error`]]
-[[Note:] [this function resides in namespace `boost::this_task`]]
-]
-
-[endsect]
-
-
 [section:get_pool Non-member function `get_pool()`]
 
 ``

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-28 16:02:09 EDT (Tue, 28 Jul 2009)
@@ -12,13 +12,6 @@
 runs in a __thread_pool__).
 
 
-[heading reschedule_until]
-
-In the function `boost::this_task::reschedule_until( Pred const&)` allows to synchronize the task with other asynchronous events
-without blocking the __worker_threads__ (bool Pred::operator()() must not block). The current task will be rescheduled until the
-passed predicate becomes true.
-
-
 [heading get_pool]
 
 The pool in which the current code (__task__) is executed can be accessed via __fn_get_pool__. If hte code is not executed by a

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-28 16:02:09 EDT (Tue, 28 Jul 2009)
@@ -30,7 +30,6 @@
 exe interrupt : interrupt.cpp ;
 exe pending : pending.cpp ;
 exe priority : priority.cpp ;
-exe reschedule_until : reschedule_until.cpp ;
 exe shutdonw_now : shutdown_now.cpp ;
 exe smart : smart.cpp ;
 exe submit : submit.cpp ;

Deleted: sandbox/task/libs/task/examples/reschedule_until.cpp
==============================================================================
--- sandbox/task/libs/task/examples/reschedule_until.cpp 2009-07-28 16:02:09 EDT (Tue, 28 Jul 2009)
+++ (empty file)
@@ -1,178 +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 <cerrno>
-#include <cstddef>
-#include <cstring>
-#include <iostream>
-#include <cstdlib>
-#include <stdexcept>
-#include <string>
-
-#include "boost/task/detail/config.hpp"
-
-# if defined(BOOST_POSIX_API)
-extern "C"
-{
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-}
-# endif
-
-#include <boost/assert.hpp>
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/thread.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::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)
-{
- printf("fibonacci(%d) == %d\n", n, parallel_fib_( n, 5) );
-}
-
-# if defined(BOOST_POSIX_API)
-bool has_bytes( int fd)
-{
- char buffer[1];
-
- int n = ::recv(
- fd,
- & buffer,
- sizeof buffer,
- MSG_PEEK | MSG_DONTWAIT);
- if ( n == -1 && errno != EWOULDBLOCK)
- {
- printf("::recv() failed: %s(%d)\n", std::strerror( errno), errno);
- ::exit( 1);
- }
-
- return n > 0;
-}
-
-void do_read( int fd)
-{
- int nread = 0;
- do
- {
- boost::this_task::reschedule_until(
- boost::bind(
- has_bytes,
- fd) );
-
- char buffer[4096];
- int n = ::read( fd, buffer, sizeof( buffer) );
- if ( n < 0)
- {
- printf("::read() failed: %s(%d)\n", std::strerror( errno), errno);
- ::exit( 1);
- }
- nread += n;
- printf("%s\n", std::string( buffer, n).c_str() );
- }
- while ( nread < 12);
-}
-
-void do_write( int fd, std::string const& msg)
-{
- if ( ::write( fd, msg.c_str(), msg.size() ) < 0)
- {
- printf("::write() failed: %s(%d)\n", std::strerror( errno), errno);
- ::exit( 1);
- }
-}
-
-void create_sockets( int fd[2])
-{
- if ( ::socketpair( PF_LOCAL, SOCK_STREAM, 0, fd) < 0)
- {
- printf("::pipe() failed: %s(%d)\n", std::strerror( errno), errno);
- ::exit( 1);
- }
-}
-# endif
-
-int main( int argc, char *argv[])
-{
-# if defined(BOOST_POSIX_API)
- try
- {
- pool_type pool( tsk::poolsize( 5) );
-
- int fd[2];
- create_sockets( fd);
-
- tsk::async(
- tsk::make_task( do_read, fd[0]),
- pool);
-
- do_write( fd[1], "Hello ");
- boost::this_thread::sleep( pt::seconds( 1) );
-
- for ( int i = 0; i < 10; ++i)
- tsk::async(
- tsk::make_task( parallel_fib, i),
- pool);
-
- do_write( fd[1], "World!");
-
- return EXIT_SUCCESS;
- }
- catch ( std::exception const& e)
- { std::cerr << "exception: " << e.what() << std::endl; }
- catch ( ... )
- { std::cerr << "unhandled" << std::endl; }
-
-# endif
-
- return EXIT_FAILURE;
-}

Modified: sandbox/task/libs/task/src/worker.cpp
==============================================================================
--- sandbox/task/libs/task/src/worker.cpp (original)
+++ sandbox/task/libs/task/src/worker.cpp 2009-07-28 16:02:09 EDT (Tue, 28 Jul 2009)
@@ -41,10 +41,6 @@
 { return impl_->try_steal( ca); }
 
 void
-worker::reschedule_until( function< bool() > const& pred)
-{ return impl_->reschedule_until( pred); }
-
-void
 worker::run()
 {
         // FIXME: ugly
@@ -52,6 +48,14 @@
         impl_->run();
 }
 
+void
+worker::reschedule_until( function< bool() > const& pred)
+{ impl_->reschedule_until( pred); }
+
+bool
+worker::block()
+{ return impl_->block(); }
+
 worker *
 worker::tss_get()
 { return worker::tss_.get(); }


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