Boost logo

Boost :

Subject: Re: [boost] [coroutine] Experimenting with interfaces
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2012-09-21 14:34:00


Am 21.09.2012 20:15, schrieb Eugene Yakubovich:
>>
>> 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().
>
in the modified example timer() never yields (c(interval) is not called)
- it simple returns.
no value was transfered from coroutine function to the caller ->
coroutines must return the type of the signature


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