File tree 1 file changed +5
-2
lines changed
include/onnxruntime/core/platform
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1470,8 +1470,11 @@ class ThreadPoolTempl : public onnxruntime::concurrency::ExtendedThreadPoolInter
1470
1470
void SetBlocked (std::function<bool ()> should_block,
1471
1471
std::function<void()> post_block) {
1472
1472
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
+ }
1475
1478
if (should_block ()) {
1476
1479
status.store (ThreadStatus::Blocked, std::memory_order_relaxed);
1477
1480
do {
You can’t perform that action at this time.
0 commit comments