From 35f2461bc816500fa59235c1751138520099fc07 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Fri, 13 Dec 2024 19:15:11 +0000 Subject: [PATCH] update --- .../onnxruntime/core/platform/EigenNonBlockingThreadPool.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/onnxruntime/core/platform/EigenNonBlockingThreadPool.h b/include/onnxruntime/core/platform/EigenNonBlockingThreadPool.h index 27b14f008a8ba..2e758994179a8 100644 --- a/include/onnxruntime/core/platform/EigenNonBlockingThreadPool.h +++ b/include/onnxruntime/core/platform/EigenNonBlockingThreadPool.h @@ -1470,8 +1470,11 @@ class ThreadPoolTempl : public onnxruntime::concurrency::ExtendedThreadPoolInter void SetBlocked(std::function should_block, std::function post_block) { std::unique_lock lk(mutex); - assert(GetStatus() == ThreadStatus::Spinning); - status.store(ThreadStatus::Blocking, std::memory_order_relaxed); + auto old_status = status.exchange(ThreadStatus::Blocking, std::memory_order_seq_cst); + if (old_status != ThreadStatus::Spinning) { + // Encountered a logical error + throw std::runtime_error("The state transition is not allowed"); + } if (should_block()) { status.store(ThreadStatus::Blocked, std::memory_order_relaxed); do {