This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 0bb01ee9 Use condition argument of cv.wait instead of loop (#2043)
0bb01ee9 is described below
commit 0bb01ee9075851aaaf104830b50969913ce080a5
Author: Twice <[email protected]>
AuthorDate: Tue Jan 23 18:01:46 2024 +0900
Use condition argument of cv.wait instead of loop (#2043)
Co-authored-by: hulk <[email protected]>
---
src/cluster/slot_migrate.cc | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/cluster/slot_migrate.cc b/src/cluster/slot_migrate.cc
index 424d0b4c..be54cc2e 100644
--- a/src/cluster/slot_migrate.cc
+++ b/src/cluster/slot_migrate.cc
@@ -151,11 +151,10 @@ Status SlotMigrator::CreateMigrationThread() {
void SlotMigrator::loop() {
while (true) {
- std::unique_lock<std::mutex> ul(job_mutex_);
- while (!isTerminated() && !migration_job_) {
- job_cv_.wait(ul);
+ {
+ std::unique_lock<std::mutex> ul(job_mutex_);
+ job_cv_.wait(ul, [&] { return isTerminated() || migration_job_; });
}
- ul.unlock();
if (isTerminated()) {
clean();