File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -116,17 +116,23 @@ bool TaskGroup::is_stopped(bthread_t tid) {
116116}
117117
118118bool TaskGroup::wait_task (bthread_t * tid) {
119+ int64_t poll_start_ms = butil::cpuwide_time_ms ();
119120 do {
120121#ifndef BTHREAD_DONT_SAVE_PARKING_STATE
121122 if (_last_pl_state.stopped ()) {
122123 return false ;
123124 }
124125
125- if (pop_resume_task (tid)) {
126+ if (pop_resume_task (tid) || steal_task (tid) ) {
126127 return true ;
127128 }
128129
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+
130136 if (steal_task (tid)) {
131137 return true ;
132138 }
You can’t perform that action at this time.
0 commit comments