-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
capy::thread_pool thd_pool;
capy::Executor auto ex = thd_pool.get_executor();
// ex.context().make_service<capy::detail::timer_service>(); // this line commented out causes ThreadSanitizer warning
std::latch done(no_of_tasks);
auto delay_task = [&](size_t index) -> capy::task<void> {
co_await capy::delay(10ms * index);
};
for (int i = 0; i < no_of_tasks; ++i)
{
capy::run_async(thd_pool.get_executor(), [&]() { done.count_down(); }, [&](std::exception_ptr) { done.count_down(); })(delay_task(i));
}
thd_pool.join();
done.wait();Tests using capy::delay run on a thread_pool{1}. When the pool contains more threads, ThreadSanitizer reports a warning.
Should the timer_service- or any other service used by the execution context - be created before running any asynchronous tasks, or is it safely and lazily created on demand in await_suspend() (in this case inside delay_awaitable with ts_ = &env->executor.context().use_service<detail::timer_service>())?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels