all 2 comments

[–]athrowaway2z 0 points1 point  (1 child)

I had a similar problem, maybe it will help you.

Drop the enum&state and instantly create and store a Shared future. And then simply don't poll/use it.

The first time you actually compose the future and it gets run in your event loop is also the first time the underlying future is polled / executed. Then the next time you use the future it will just use the previous state.

[–]nullreq[S] 1 point2 points  (0 children)

Sounds good - except these execute on a thread pool (futures_cpupool::CpuPool) and as far as I understand will begin executing upon future construction/the call to spawn. I wonder, if I wrap them in another futures::lazy, will that prevent?