libunifex
libunifex copied to clipboard
usage of current_scheduler inside of coroutine
Is it expected that next code doesn't work?
timed_single_thread_context ctx;
auto makeTask = [&]() -> task<int> {
co_return co_await via(schedule(current_scheduler), just(42));
};
sync_wait(with_query_value(makeTask(), get_scheduler, ctx.get_scheduler()));
The task
coroutine type does not yet support transparent propagation of execution context/scheduler to its child operations so your example's usage of current_scheduler
inside the coroutine won't work.
This is something we plan to eventually add support for though and is, imo, an essential feature for the design of a standard task type.
Thanks for clarification!
This should be resolved with PR #506.