
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