Boost logo

Boost :

Subject: Re: [boost] [tasklet] micro-tasks with cooperative scheduler
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-03-18 20:40:19


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-scheduler-tp3388647p3388809.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk