cplusplus / sender-receiver

Issues list for P2300
Apache License 2.0
19 stars 3 forks source link

Add `detach_on_cancel` algorithm for async-scopes #265

Open lewissbaker opened 3 months ago

lewissbaker commented 3 months ago

There are use-cases where an operation does not natively support cancellation but where a consumer wants to be able to detach promptly from waiting for the operation to complete when the result is no longer required.

The existing nest() basis operation that is proposed by the async_scope paper has the semantics that it just forwards the stop-request to the nested operation and waits for it to complete.

As detaching from an operation leaves that operation to continue running in the background, the detachable operation needs to be associated with an async-scope so that we can at least later join that detached work.

The semantics of a detach_on_cancel() operation would be:

sender auto detach_on_cancel(sender auto&& sender, async_scope_token scope);

When invoked: