Boost logo

Boost :

Subject: Re: [boost] Asynchronous library now in Boost Library Incubator
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2016-12-01 15:45:52


On 12/01/2016 03:04 PM, Biddiscombe, John A. wrote:

>
> For you and any others reading this, the main hpx docs are here http://stellar-group.github.io/hpx/docs/html/ but there is useful additional material in the form of tutorial slides https://stellar-group.github.io/tutorials/#1 and they link to a number of examples - though the main hpx repo has an examples directory with many more of them.
>

Thanks.

>>>
> I understood HPX as a library returning futures to calls to asynchronous functions, somewhat similar to std::async.
> In that case, the main region with all the futures would be a thread world for asynchronous. In huge applications, this does not solve the problem of organizing thousands of objects within threads.
> <<
> Yes, I suppose that the whole application would be a single thread world using that analogy. Objects are not 'bound' to a particular thread, they can be accessed freely from any thread and the user is responsible for protecting them - or preferably writing functional-like code to avoid collisions etc.
>
>
>>>
>> A future .then() or continuation is really just a type of callback too (broadly speaking).
>
> Not really, if I understand correctly
> (http://en.cppreference.com/w/cpp/experimental/future/then). The functor object passed to then() is executed in an unspecified thread of execution, which makes it hard for the caller to (safely) pass data which might or might not be valid or relevant at the time the then functor executes.
> I however could not find out whether this also applied to HPX.
> <<
>
> In HPX there are launch policies that can be used to control thread execution, the one that would come closest to what you are looking for would be
>
> future<thing> = hpx::async(do_something_interesting()).then(hpx::launch::sync, do_another_interesting_thing());
>
> This tells the .then() continuation to execute the next function in the same context as the thread that completes the initial future.

Does it mean a threadpool thread or the thread which started the
asynchronous task?

<snip>

> I didn't quite understand the state machine explanation - but I'll continue looking through the boost.asynchronous material until I am happier.

I tried to add an example and the underlying rationale
(https://htmlpreview.github.io/?https://github.com/henry-ch/asynchronous/blob/master/libs/asynchronous/doc/asynchronous.html#d0e6437).

The Manager is a very simplified state machine but I hope you get the idea.

Cheers,
Christophe


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