Skip to content

Commit 35f2461

Browse files
committed
update
1 parent 62e7e24 commit 35f2461

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

include/onnxruntime/core/platform/EigenNonBlockingThreadPool.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -1470,8 +1470,11 @@ class ThreadPoolTempl : public onnxruntime::concurrency::ExtendedThreadPoolInter
14701470
void SetBlocked(std::function<bool()> should_block,
14711471
std::function<void()> post_block) {
14721472
std::unique_lock<std::mutex> lk(mutex);
1473-
assert(GetStatus() == ThreadStatus::Spinning);
1474-
status.store(ThreadStatus::Blocking, std::memory_order_relaxed);
1473+
auto old_status = status.exchange(ThreadStatus::Blocking, std::memory_order_seq_cst);
1474+
if (old_status != ThreadStatus::Spinning) {
1475+
// Encountered a logical error
1476+
throw std::runtime_error("The state transition is not allowed");
1477+
}
14751478
if (should_block()) {
14761479
status.store(ThreadStatus::Blocked, std::memory_order_relaxed);
14771480
do {

0 commit comments

Comments
 (0)