Boost logo

Boost :

Subject: Re: [boost] [fiber] mini review - symmetric a. asymmetric continuation
From: Oliver Kowalke (k-oli_at_[hidden])
Date: 2011-02-10 03:34:26

Am 10.02.2011 02:10, schrieb Daniel Larimer:
> I am working on a project that will be using your fiber library in a manner similar to how sym_fiber is intended. Before you released this update I was planning a design using the asym_fiber (which looks like the old 'fiber') that would simply call 'run()' on the fiber it intended to 'switch to' under the assumption that I could have any other fiber 'resume' by calling run on it again. The only apparent difference is that with 'yield()' you go back to the caller and with run() you go to some other context (which could also be the caller).
> Perhaps I am missing something fundamental, but I didn't see a need for two different fiber's.
> fiber a(funcA);
> fiber b(funcB);
> void funcA()
> {
>; // == a.switch_to(b);
> }
> void funcB()
> {
>; // == b.switch_to(a);
> }

asymmetric fiber provide two control-transfer operations:
asym_fiber::run() activates the continuation point of this fiber ==
execution control is transfered to the fiber
asym_fiber::yield() saves the continuation point of the fiber ==
execution control is transfered to the invoker of this fiber
for asym_fiber it is characteristic that it returns always to its
invoker. Providing two functions makes the semantic of the transfer
operations more explicit: run() -> activate, yield() -> deactivate.
With only one operation it would not be clear if the fiber will be
activated or deactivated.

a sequence of invocation with asymmetric fibers looks like this:

fiber A -> fiber B -> fiber A
fiber A -> fiber C -> fiber A
fiber A -> fiber D -> fiber A

each invocation of fibers B, C, D returns to fiber A.

symmetric fibers provide only one transfer operation:
sym_fiber::switch_to() transfers execution control to a arbitrary fiber
In contrast to asym_fiber the sym_fiber does not return to its invoker.
The fiber switch is more explicit

a sequence of invocation with symmetric fibers looks like this:

fiber A -> fiber -> fiber C -> fiber D -> fiber A

Boost list run by bdawes at, gregod at, cpdaniel at, john at