Skip to content

Commit a6fe522

Browse files
authored
use thread_yield instead of thread_yield_to in workerpool (alibaba#968)
* use thread_yield instead of thread_yield_to in workerpool
1 parent 685525f commit a6fe522

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

thread/workerpool.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ class WorkPool::impl {
131131
} else {
132132
auto th = !pool ? thread_create(&delegate_helper, &tasklb) :
133133
pool-> thread_create(&delegate_helper, &tasklb) ;
134-
// yield to th so as to copy tasklb to th's stack
135-
photon::thread_yield_to(th);
134+
(void)th;
135+
// Once yield the current coroutine, the newly created coroutine will always
136+
// be scheduled before the current coroutine. tasklb will not be overwritten.
137+
photon::thread_yield();
136138
}
137139
}
138140
while (running_tasks)

0 commit comments

Comments
 (0)