yield current task in single-threaded coroutine scheduler on spawn
This schedules tasks more aggressively, letting side tasks always run.master
parent
67525af4e5
commit
ec9ddb2aad
|
@ -461,6 +461,7 @@ struct basic_thread_scheduler: scheduler {
|
|||
}
|
||||
|
||||
void do_spawn(std::function<void()> func) {
|
||||
{
|
||||
std::lock_guard<std::mutex> l{p_lock};
|
||||
p_threads.emplace_front();
|
||||
auto it = p_threads.begin();
|
||||
|
@ -469,6 +470,8 @@ struct basic_thread_scheduler: scheduler {
|
|||
remove_thread(it);
|
||||
}};
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
void yield() noexcept {
|
||||
std::this_thread::yield();
|
||||
|
@ -719,6 +722,7 @@ public:
|
|||
|
||||
void do_spawn(std::function<void()> func) {
|
||||
p_coros.emplace_back(std::move(func), p_stacks.get_allocator());
|
||||
yield();
|
||||
}
|
||||
|
||||
void yield() noexcept {
|
||||
|
|
Loading…
Reference in New Issue