libunifex icon indicating copy to clipboard operation
libunifex copied to clipboard

usage of current_scheduler inside of coroutine

Open StepanPieshkin opened this issue 3 years ago • 3 comments

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()));

StepanPieshkin avatar Dec 13 '20 20:12 StepanPieshkin

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.

lewissbaker avatar Dec 13 '20 21:12 lewissbaker

Thanks for clarification!

StepanPieshkin avatar Dec 14 '20 07:12 StepanPieshkin

This should be resolved with PR #506.

ispeters avatar May 11 '23 17:05 ispeters