Add coroutine traits metafunctions to folly::coro
Summary: Adds four template metafunctions that can be used when building generic coroutine code. - `is_awaitable<T>`, `is_awaitable_v<T>` Query whether a type can be co_awaited within a "normal" coroutine. - `is_awaiter<T>`, `is_awaiter_v<T>` Query whether a type implements the `await_ready()`, `await_suspend()` and `await_resume()` methods required for the 'Awaiter' concept. - `awaiter_type<T>`, `awaiter_type_t<T>` Query what the 'Awaiter' type is for a given 'Awaitable' type. This will be the return-type of whatever `operator co_await()` returns, if one is defined, otherwise is type of the Awaitable itself. - `await_result<T>`, `await_result_t<T>` Query what the type resulting from applying the `co_await` operator to a value of type, `T`. - Moved the existing `folly::coro::get_awaiter()` implementation from 'AwaitWrapper.h' into 'Traits.h'. Note that these traits all currently assume that the `co_await` operator appears within a coroutine that does not provide an `await_transform()` customisation point. A promise type that implements the `await_transform()` customisation point can arbitrarily change the behaviour of a `co_await` that occurs within its body. Reviewed By: andriigrynenko Differential Revision: D9382593 fbshipit-source-id: e9ddfec4a62579a4b2649c070e53e8639e7c68a1
Showing
Please register or sign in to comment