Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2006-10-19 05:01:34


Hi Peter,

On 10/19/06, Peter Dimov <pdimov_at_[hidden]> wrote:
> Dean Michael Berris wrote:
>
> > I had been more or less influenced by Herb Sutter's presentation on
> > the Concur project and the idea of:
> >
[snipped code example]

>
> It isn't clear to me how this simple model can handle synchronization
> constraints; do all "active calls" run in parallel? Sequentially? What if I
> want some of them to run in parallel and some of them to obey sequential
> consistency?
>

It seems that the simplistic approach leaves a lot to the (compiler)
implementation to decide (barring any more additional keywords aside
from `active' to be added just for modifying the concurrency
implementation). However for all intents and purposes, it seems to me
that behind the scenes (and adhering to the Active Object Pattern)
there would be a single scheduler for a single active object (perhaps
using something similar to io_service).

> Given an appropriate Executor (as in N2096), it's easy to emulate
> asynchronous calls as
>
> future<int> r = ex.execute( bind( &my_class::f, &instance ) );
>
> or maybe even
>
> future<int> r = active( &my_class::f, &instance );
>
> // future<int> r = active { instance.f() } in Concur?
>
> if we trust the implementation to provide an optimal default executor (an
> adaptive thread pool, most likely.)
>

I like the above examples a lot, and would like to be able to do
something even like:

future<int> r = active<new_thread>(&my_class::f, &instance);
future<int> r = active<queued>(&my_class::f_other, &instance);

> But the real world is usually not as simple.

Indeed. That's why we had to hand-roll our own solution and
profile-optimize for our specific situation, though it would be nice
to have something flexible and generic enough for a good subset of the
very many cases in which you'd want concurrency support in C++ written
applications.

-- 
Dean Michael C. Berris
C++ Software Architect
Orange and Bronze Software Labs, Ltd. Co.
web: http://software.orangeandbronze.com/
email: dean_at_[hidden]
mobile: +63 928 7291459
phone: +63 2 8943415
other: +1 408 4049532
blogs: http://mikhailberis.blogspot.com http://3w-agility.blogspot.com
http://cplusplus-soup.blogspot.com

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