From 924f90cf9a7455d13f11f2d7f43ac1a3074bb481 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 22 Jun 2021 20:03:25 +0800 Subject: [PATCH] crimson/os: reduce the scope of lock we just need to synchronize accesses to `stopping`, so only need to guard the mutation of it. Signed-off-by: Kefu Chai --- src/crimson/os/alienstore/thread_pool.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/crimson/os/alienstore/thread_pool.h b/src/crimson/os/alienstore/thread_pool.h index fd22c9743db..25bd782d701 100644 --- a/src/crimson/os/alienstore/thread_pool.h +++ b/src/crimson/os/alienstore/thread_pool.h @@ -90,8 +90,10 @@ public: return work_item; } void stop() { - std::unique_lock lock{mutex}; - stopping = true; + { + std::unique_lock lock{mutex}; + stopping = true; + } cond.notify_all(); } void push_back(WorkItem* work_item) { -- 2.39.5