Subject: Re: [boost] Asynchronous library now in Boost Library Incubator
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2016-12-04 09:56:21
> > 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.
> > <<
Why not? You can easily (and I mean it) create asynchronous applications
solely using futures for defining the necessary dependencies between tasks,
running millions of tasks.
> > 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.
HPX uses executors to fine-control where which task is executed. Every
function which (potentially) creates a new task can optionally be used with
an instance of an executor (async(), future::then(), 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.
By default in HPX the continuation is executed on the thread which has made
the future ready.
> > 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> =
> > 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?
The thread which makes the future ready. But executors can be used to
control the concrete thread (see above).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk