Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keep_future algorithm #5323

Merged
merged 1 commit into from May 18, 2021
Merged

Conversation

msimberg
Copy link
Contributor

This solves the problem of trying to use a shared_future<noncopyable_type> with e.g. on or sync_wait which fails because the algorithms have to copy the value internally (which obviously does not work with noncopyable types). This adds a wrapper algorithm keep_future (other name suggestions?) which calls set_value on receivers connected to futures with the future instead of the contained value.

Note: This could very well be a better default than the current implementation of futures as senders. There's always unwrapping for dealing with futures in continuations.

Builds on #5274 since it requires some fixes to on. Only the last commit is new.

@msimberg msimberg added the category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals label May 10, 2021
@msimberg msimberg added this to the 1.7.0 milestone May 10, 2021
@msimberg msimberg force-pushed the keep_future branch 4 times, most recently from 9bdc9ce to b94b80d Compare May 14, 2021 07:56
@msimberg msimberg marked this pull request as ready for review May 14, 2021 07:58
hkaiser
hkaiser previously approved these changes May 15, 2021
Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go ahead with this, LGTM. Thanks!

@msimberg
Copy link
Contributor Author

Let's go ahead with this, LGTM. Thanks!

Note that this includes #5274. No further comments on that?

… continuations when futures are used as senders

keep_future passes the future instead of the value to help manage future
lifetimes. Especially shared_future | on | ... is not possible without
this helper if the wrapped value in the future is noncopyable (since
shared_future::get returns a const& and on cannot store a const&, nor
does it need to keep the operation state alive long enough).
@msimberg msimberg merged commit 7f96e82 into STEllAR-GROUP:master May 18, 2021
@msimberg msimberg deleted the keep_future branch May 18, 2021 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants