[tasklet] micro-tasks with cooperative scheduler

Hi, I've uploaded version 0.2.0 of boost.tasklet: http://www.boostpro.com/vault/index.php?action=downloadfile&filename=boost.tasklet-0.2.0.zip&directory=Concurrent%20Programming& boost.tasklet provides a framework for cooperatively scheduling micro-tasks (some kind of user-level threads). It comes with an scheduler, synchronisation primitives - mutex, condition, barrier, event-variables (auto- and manual-reset and count-down variable), future and channel. boost::tasklets::packaged_task< std::string > pt( helloworld_fn); boost::tasklets::unique_future< std::string > fu = pt.get_future(); boost::tasklet t( boost::move( pt), boost::tasklet::default_stacksize); boost::scheduler::schedule( t); boost::scheduler::schedule( my_function, 1, "abc"); for (;;) { while ( boost::scheduler::run() ); if ( boost::scheduler::empty() ) break; } std::cout << fu.get() << std::endl; In order to let functions/actions be executed in a separate thread boost.tasklet provides a scheduler_thread: boost::scheduler_thread st; boost::shared_future< void > f1( st.schedule( some_fn ) ); boost::shared_future< std::string > f2( st.schedule( other_fn) ); f1.wait(); std::cout << "future 2 result: " << f2.get() << std::endl; regards, Oliver

Oliver Kowalke wrote:
Hi,
I've uploaded version 0.2.0 of boost.tasklet: http://www.boostpro.com/vault/index.php?action=downloadfile&filename=boost.tasklet-0.2.0.zip&directory=Concurrent%20Programming&
Hi Oliver. Thanks for showing another application of Boost.Context. I hope that this will motivate some boosters to participate in the review that will start next Monday Mars 21.
boost.tasklet provides a framework for cooperatively scheduling micro-tasks (some kind of user-level threads). It comes with an scheduler, synchronisation primitives - mutex, condition, barrier, event-variables (auto- and manual-reset and count-down variable), future and channel.
boost::tasklets::packaged_task< std::string > pt( helloworld_fn); boost::tasklets::unique_future< std::string > fu = pt.get_future(); boost::tasklet t( boost::move( pt), boost::tasklet::default_stacksize);
boost::scheduler::schedule( t); boost::scheduler::schedule( my_function, 1, "abc"); for (;;) { while ( boost::scheduler::run() ); if ( boost::scheduler::empty() ) break; }
std::cout << fu.get() << std::endl;
What about using the async world from the standard to lunch tasklets? tasklets::async(t); tasklets::async(my_function, 1, "abc"); If we add a tag type namespace tasklets { struct executor_tag {}; static const executor_tag executor; }; you could overload async so we can call it this way async(tasklets::executor, t); async(tasklets::executor, my_function, 1, "abc"); which make code a little bit more uniform (respect to the standard of course). What do you think about moving all the public classes (scheduler, tasklet) to the tasklets namespace.
In order to let functions/actions be executed in a separate thread boost.tasklet provides a scheduler_thread:
boost::scheduler_thread st;
boost::shared_future< void > f1( st.schedule( some_fn ) ); boost::shared_future< std::string > f2( st.schedule( other_fn) );
f1.wait(); std::cout << "future 2 result: " << f2.get() << std::endl;
The async function could be overloaded to allow calls as async(st, some_fn); BTW, there is yet at least a use of 'submit' in the doc from preceding versions. Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/tasklet-micro-tasks-with-cooperative-sche... Sent from the Boost - Dev mailing list archive at Nabble.com.

boost.tasklet provides a framework for cooperatively scheduling micro-tasks (some kind of user-level threads). It comes with an scheduler, synchronisation primitives - mutex, condition, barrier, event-variables (auto- and manual-reset and count-down variable), future and channel.
boost::tasklets::packaged_task< std::string> pt( helloworld_fn); boost::tasklets::unique_future< std::string> fu = pt.get_future(); boost::tasklet t( boost::move( pt), boost::tasklet::default_stacksize);
boost::scheduler::schedule( t); boost::scheduler::schedule( my_function, 1, "abc"); for (;;) { while ( boost::scheduler::run() ); if ( boost::scheduler::empty() ) break; }
std::cout<< fu.get()<< std::endl;
What about using the async world from the standard to lunch tasklets?
tasklets::async(t); tasklets::async(my_function, 1, "abc");
If we add a tag type
namespace tasklets { struct executor_tag {}; static const executor_tag executor; };
you could overload async so we can call it this way
async(tasklets::executor, t); async(tasklets::executor, my_function, 1, "abc");
which make code a little bit more uniform (respect to the standard of course).
What do you think about moving all the public classes (scheduler, tasklet) to the tasklets namespace.
The previous version of boost.task already supported async() with taslets/coop. scheduler - but the current version doesn't work with tasklets-0.2.0. I start refactoring boost.task soon - so all will play together. regards, Oliver

Am 19.03.2011 01:40, schrieb Vicente Botet:
What do you think about moving all the public classes (scheduler, tasklet) to the tasklets namespace.
The classes are declared in namespace boost::tasklets. I've put an using declaration in namespace boost - isn't it appropriated? regards, Oliver

Oliver Kowalke wrote:
Am 19.03.2011 01:40, schrieb Vicente Botet:
What do you think about moving all the public classes (scheduler, tasklet) to the tasklets namespace.
The classes are declared in namespace boost::tasklets.
This is good.
I've put an using declaration in namespace boost - isn't it appropriated?
I recall a thread about avoiding polluting the boost namespace and requiring a good reason to do so. I think we can try without the using and if the code is not readable then look for alternatives that should be discussed in this ML. Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/tasklet-micro-tasks-with-cooperative-sche... Sent from the Boost - Dev mailing list archive at Nabble.com.
participants (2)
-
Oliver Kowalke
-
Vicente Botet