Skip to content

Commit

Permalink
Fix cancel (PaddlePaddle#36740)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
liutiexing authored and piotrekobi committed Nov 3, 2021
1 parent 0c1fe32 commit b2cc0c6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions paddle/fluid/framework/new_executor/nonblocking_threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,16 @@ class ThreadPoolTempl {
// We already did best-effort emptiness check in Steal, so prepare for
// blocking.
ec_.Prewait();
if (cancelled_) {
ec_.CancelWait();
return false;
}
// Now do a reliable emptiness check.
int victim = NonEmptyQueueIndex();
if (victim != -1) {
ec_.CancelWait();
if (cancelled_) {
return false;
} else {
*t = thread_data_[victim].queue.PopBack();
return true;
}
*t = thread_data_[victim].queue.PopBack();
return true;
}
// Number of blocked threads is used as termination condition.
// If we are shutting down and all worker threads blocked without work,
Expand Down

0 comments on commit b2cc0c6

Please sign in to comment.