Boost logo

Boost :

Subject: Re: [boost] [coroutine] new versions
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-10-05 18:20:18


Le 05/10/12 21:46, Oliver Kowalke a écrit :
> Am 05.10.2012 21:27, schrieb Vicente J. Botet Escriba:
>> The single difference between both interfaces is that with fist the
>> return is obtained using yield, while in the second is using the
>> operator().
>
> the main difference between version 1 and 2 is that self_t is not a
> coroutine<> it is a different type.
I don't think the caller should be taken as a coroutine, as it could not
be one.
> Version 2 was suggested by Giovanni and Eugene - especially Eugene has
> provided an example demonstrating the benefit of version 2:
>
>
>> I prefer to use yield to return a result and the call operator to
>> call to a coroutine.
> because slef_t is not of type coroutine<> I expressed the context jump
> function as 'yield()' instead of operator()
>
>> It is not enough clear to me what are the advantages of having a
>> inversed coroutine as parameter.
> If you use symmetric coroutines - see example above
Symmetric coroutines are a different thing than your caller_t type, even
if the caller is a coroutine. Symmetric coroutines lets the called
coroutine to yield in place of the calling one. I don't see how this
inversion helps to achieve symmetric coroutines. I should be missing
something basic. Of course, I'm completely for the addition of symmetric
coroutines.
>
>>
>> Anyway, maybe the use of the get accessor can be made more readable
>> without effort using tags
>>
>> struct a{};
>> struct b{};
>> typedef coroutine< int( tagged<int, a>, tagged<int,b> > > coro_t;
>> int fn( coro_t::self_t & c) {
>> int x = c.get< a >();
>> int y = c.get< b >();
>> c.yield( x +y);
>> ...
>> }
>>
> does boost.tuple provide such a facility?

If Boost.Tuple doesn't provides them, Boost.Fusion tuple provides them
already.

Best,
Vicente


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