Boost logo

Boost Users :

Subject: [Boost-users] [coroutine] new versions
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2012-10-05 11:22:40


I've uploaded two re-factored versions - I think most of the suggestions
from the review are implemented (namespace is not corrected and
documentation not updated yet).

1.) http://ok73.ok.funpic.de/boost-coroutine-self.zip
2.) http://ok73.ok.funpic.de/boost-coroutine-coro.zip

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.

typedef coroutine< int( int, int> > coro_t;
int fn( coro_t::self_t & c) {
     int x = c.get< 0 >();
     int y = c.get< 1 >();
     c.yield( x +y);
     ...
}
coro_t coro( fn);
int res = c( 3, 7).get();

Version 2) requires that coroutine-fn has only one argument too ==
coroutine<> with inverted signature. Other arguments are access via
coroutine<>::get().
interface provides input/output iterators.

typedef coroutine< int( int, int> > coro_t;
int fn( coroutine< tuple< int, int >( int) & 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();

Both implementations are not optimized - I think we should get a small
and clean interface first.
Comments?

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