Integrate CancellationToken support into Task
Summary: The `folly::coro::Task` coroutine type now has an associated `CancellationToken` that is implicitly passed down to child operations that it awaits. This is a first step towards supporting cancellation of persistent async streams. This adds a new `co_withCancellation()` customisation point that awaitable types can customise to allow them to opt-in to cancellation. Currently only `Task` customises this operation. Also provided a new `co_current_cancellation_token` object that can be awaited within a `Task` to retrieve the current `CancellationToken`. Note that I have not yet hooked up the `Future` or `SemiFuture` to integrate with this cancellation mechanism (most `Future`-based code is not cancellation-aware). So a coroutine that is currently suspended awaiting for a `Future` may not currently respond to a cancellation request. Reviewed By: andriigrynenko Differential Revision: D16610810 fbshipit-source-id: 72a31d7a3ba4c281db54c1942ab41d4ea2f34d21
Showing
Please register or sign in to comment