Boost logo

Boost :

Subject: Re: [boost] [coroutine] Experimenting with interfaces
From: Eugene Yakubovich (eyakubovich_at_[hidden])
Date: 2012-09-21 14:15:46


On Fri, Sep 21, 2012 at 12:34 PM, Oliver Kowalke <oliver.kowalke_at_[hidden]> wrote:
>
> thank you for your examples:
> If coroutine's template signature returns a type different from void it is
> required that the coroutine function does return the same type instead of
> void as in your example.

I understand but what I was doing is exploring interfaces that were
most natural to the problem I was trying to solve. And it seems that
having a coroutine function return void (even if coro signature's
return value is non-void) is useful. Also, Giovanni's proposed
interface essentially has a void return type.

>
>
> template <typename C>
> void timer(C c, chrono::seconds interval) {
> // while( interval != chrono::seconds::zero() ) {
> // this_thread::sleep_for(interval);
> // interval = c(interval);
> // }
>
> }
>
> coroutine<chrono::seconds(chrono::seconds)> c(
> [](coroutine<chrono::seconds(chrono::seconds)> c, chrono::seconds i) {
> timer(c, i);
> }
> );
>
> chrono::seconds s = c(chrono::seconds(1));
>
>
> Which value has variable 's' after return from 'c(chrono::seconds(1))' ?

chrono::seconds(1) since timer() yields whatever was initially passed
in and then whatever was returned by c().

Regards,
Eugene


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