Boost logo

Boost :

Subject: Re: [boost] Boost.Coroutine
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2010-03-03 03:57:36


Ok, so my example below was not quite accurate. In reality I was trying to wait on two futures at once. If I switch it to wait on just one then it all works. It appears to be unhappy with one of
my futures that didn't "return" going out of scope. I only care about one OR the other, but not both.

Is there a way to cancel?

I can work around only being able to have "one" return type for my future, but thought the multiple future route made the most sense.

Dan

On Mar 3, 2010, at 3:46 AM, Daniel Larimer wrote:

> I am attempting to use boost.coroutine; however, it is not behaving for me. Perhaps someone could shed some light? Here is what happens:
>
>
> 1 start coroutine A
> 2 do some work....
>
> 3 my_wait_for_value()
> 4 future<R> f(self);
                    future<Error> err(self)
> 5 callback = make_callback(f);
                   error_callback = make_callback(err)
>
> 6 r = do_wait( f, err )
> 7 boost::coroutines::wait( f, err ) // blocks and the coroutine exits , goto A
> 8 return *f;
> 9 print( "here" )
> 10 return r;
> 11 do some more work
>
>
> A start coroutine B
> B do some work
> C callback_from_coroutine_A ( R ) // goto line 8
> D ....
>
> back to line 8
>
> 8 r = *f; // got the right future value
> 9 print("here")
> 10 return r;
> 11 ?????
>
>
> After returning r on line 10, I should end up back on line 11, but instead end up on line D.
>
> I clearly setup the future, waited, started another coroutine, set the value of the future, returned 2 levels of the stack, but the 3rd level dumped me off back in a different coroutine.
>
> Running on Mac OS X 10.6. Single threaded code.
>
> Dan
>
>


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