Boost logo

Boost Users :

From: Klebsch, Mario (Mario.Klebsch_at_[hidden])
Date: 2019-09-02 12:27:11


Hello Stephan,

I have use stackless coroutines a little bit, and I think, I can explain.

> I'm puzzled about the double std::move() of self. In the comments above it says that self is a reference to an intermediate completion handler. How can this be moved twice?
> Can anyone give me hint about what this means?

The line
yield delay_timer_->async_wait(std::move(self));

terminates the function. If the async operation is complete, the function gets called again and continues at the next statement, but this time with the new, moved self.

So the next line
yield boost::asio::async_write(…, …, std::move(self));

can move self a 2nd time. When the 2nd async operation completes and execution continues on the next line, the statement
                self.complete(error);

finally operates on the 3rd instance of self.

I hope this helps,

Mario



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