facebookexperimental / facebookexperimental/libunifex

Add support for async cleanup to senders

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.7k
Forks
210
PR merge metrics
No merged PRs in 30d

Description

One of the main capabilities not yet supported by senders in libunifex is the abillity to have them perform asynchronous cleanup.

The stream abstraction has both a `next()` and a `cleanup()` operation which return senders. When you are finished with a stream you must call `cleanup()` and wait for it to complete before destroying the stream. We should be able to have the same facilities for senders.

This can allow a result to be produced with lower latency as the cleanup can be deferred until after the result has been processed.

## Some use-cases

A `stop_immediately()` algorithm for senders that immediately completes the current op with 'done' and asynchronously requests the source operation to stop. The cleanup operation would then wait for the source operation to complete.

We could make `when_all()` immediately complete with error/done in the case that one of the input senders completed with error/done. Then other operations could be cancelled and the cleanup would wait for these operations to complete.

## Reference

See also [P1662R0](https://wg21.link/P1662R0) for a discussion of Async RAII for coroutines.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.