We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ac3d8a1 commit 35f316cCopy full SHA for 35f316c
1 file changed
src/bthread/task_group.cpp
@@ -116,17 +116,23 @@ bool TaskGroup::is_stopped(bthread_t tid) {
116
}
117
118
bool TaskGroup::wait_task(bthread_t* tid) {
119
+ int64_t poll_start_ms = butil::cpuwide_time_ms();
120
do {
121
#ifndef BTHREAD_DONT_SAVE_PARKING_STATE
122
if (_last_pl_state.stopped()) {
123
return false;
124
125
- if (pop_resume_task(tid)) {
126
+ if (pop_resume_task(tid) || steal_task(tid)) {
127
return true;
128
129
- _pl->wait(_last_pl_state);
130
+ // keep polling for some time before waiting on parking lot
131
+ if (butil::cpuwide_time_ms() - poll_start_ms > 100) {
132
+ _pl->wait(_last_pl_state);
133
+ poll_start_ms = butil::cpuwide_time_ms();
134
+ }
135
+
136
if (steal_task(tid)) {
137
138
0 commit comments