Special placeholder object that can be 'co_await'ed from within a Task<T> or an AsyncGenerator<T> to obtain the current folly::Executor associated with the current coroutine.

Synopsis

Declared in <folly/coro/CurrentExecutor.h>

inline constexpr co_current_executor_t co_current_executor = co_current_executor{
    co_current_executor_t::secret_::token_};

Description

Note that for a folly::Task the executor will remain the same throughout the lifetime of the coroutine. For a folly::AsyncGenerator<T> the current executor may change when resuming from a co_yield suspend‐point.

Example:

folly::coro::Task<void> example() {
  Executor* e = co_await folly::coro::co_current_executor;
  e->add([] { do_something(); });
}

Created with MrDocs