Skip to content

Commit 704e454

Browse files
authored
Fix cancel (#36740)
* add align for WorkQueue * add spinlock * merge develop * merge * Add EventsWaiter * update * update * update Error MSG * update EventsWaiter * Add Cancel For ThreadPool * Add UT for Cancel * fix Cancel
1 parent 7de3f81 commit 704e454

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

paddle/fluid/framework/new_executor/nonblocking_threadpool.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -394,16 +394,16 @@ class ThreadPoolTempl {
394394
// We already did best-effort emptiness check in Steal, so prepare for
395395
// blocking.
396396
ec_.Prewait();
397+
if (cancelled_) {
398+
ec_.CancelWait();
399+
return false;
400+
}
397401
// Now do a reliable emptiness check.
398402
int victim = NonEmptyQueueIndex();
399403
if (victim != -1) {
400404
ec_.CancelWait();
401-
if (cancelled_) {
402-
return false;
403-
} else {
404-
*t = thread_data_[victim].queue.PopBack();
405-
return true;
406-
}
405+
*t = thread_data_[victim].queue.PopBack();
406+
return true;
407407
}
408408
// Number of blocked threads is used as termination condition.
409409
// If we are shutting down and all worker threads blocked without work,

0 commit comments

Comments
 (0)