|
Boost Users : |
Subject: Re: [Boost-users] [coroutine] new versions
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2012-10-05 14:32:48
Am 05.10.2012 20:10, schrieb Nat Linden:
> On Fri, Oct 5, 2012 at 11:22 AM, Oliver Kowalke <oliver.kowalke_at_[hidden]> wrote:
>
>> Version 1) requires that coroutine-fn has only one argument ==
>> coroutine<>::self_t. Other arguments are accessed via
>> coroutine<>::self_t::get< int >() and results via coroutine<>::get().
>> interface provides input/output iterators.
> I'm not sure this is an improvement over having yield() return a
> tuple.
yield() returns a reference to coroutine<>::self_t.
I decided to remove the parameters from the coroutine-fn signature and
let the user access them via self_t::get< N >(). Then it should be clearer
when and where the values are updated/available after a yield/resume
cycle.
>> Version 2) requires that coroutine-fn has only one argument too ==
>> coroutine<> with inverted signature.
> The signature inversion thing makes me uneasy. Although I don't yet
> have a definite case in mind, I worry that would make it difficult to
> synthesize a coroutine as a helper object in generic code that needs
> to deal with arbitrary signatures.
>
coroutine<>::caller_t is a typedef of the coroutine type expected/passed to
coroutine-fn.
typedef coroutine< int( int, int> > coro_t;
int fn( coro_t::caller_t & c) {
int x = c.get().get< 0 >();
int y = c.get().get< 1 >();
c( x +y);
...
}
coro_t coro( fn);
int res = c( 3, 7).get();
regards,
Oliver
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net