Composes a task with an async cleanup that always runs after it.
Declared in <folly/futures/Cleanup.h>
template<typename T>
folly::SemiFuture<T>
ensureCleanupAfterTask(
folly::SemiFuture<T> task,
folly::SemiFuture<folly::Unit> cleanup);
This helps compose a task with async cleanup The task result is stored until cleanup completes and is then produced The cleanup task is not allowed to fail.
This can be used with collectAll to combine multiple async resources
ensureCleanupAfterTask(collectAll(a.run(), b.run()), collectAll(a.cleanup(), b.cleanup())).wait();
A SemiFuture producing the task result after cleanup completes.
| Name | Description |
|---|---|
| task | The task whose result is produced once cleanup completes. |
| cleanup | The cleanup task run after the task; it must not fail. |