coro safe_point
Summary: Add a new concept of a safe-point to folly::Task<...> with implementation-defined semantics. Example usage: ```lang=c++ Task<> co_something() { while (is_work_available()) { co_await co_safe_point; do_work(); } } ``` Previously, a coroutine function which would cancel itself if cancellation is requested would need to spell cancellation pass-through a bit less elegantly: ```lang=c++ Task<> co_something() { while (is_work_available()) { auto token = co_await co_current_cancellation_token; if (token.isCancellationRequested()) { co_yield co_cancel; } do_work(); } } ``` Initial semantics include: * If cancellation has been requested, finish the coroutine with cancellation. * Otherwise, continue the coroutine. In the future, it may be wise to add additional behavior: * If the coroutine has been running for too long since its previous resumption, reschedule it. Reviewed By: aary Differential Revision: D25861265 fbshipit-source-id: 6da896f1529d652bfe222cf3a70e9dbe19778510
Showing
Please register or sign in to comment