From a5eec9d7b49bcb11d5da2b6ba88cee0641fa4173 Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 21 Apr 2020 01:22:18 -0500 Subject: [PATCH] create index notify (#2003) * create index notify Signed-off-by: yhmo * typo Signed-off-by: yhmo * typo Signed-off-by: groot --- core/src/db/DBImpl.cpp | 3 ++- core/src/db/DBImpl.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/db/DBImpl.cpp b/core/src/db/DBImpl.cpp index 9529b99ad3..4fe8981e25 100644 --- a/core/src/db/DBImpl.cpp +++ b/core/src/db/DBImpl.cpp @@ -1979,6 +1979,7 @@ DBImpl::BackgroundBuildIndex() { } LOG_ENGINE_DEBUG_ << "Background build index thread finished"; + index_req_swn_.Notify(); // notify CreateIndex check circle } } @@ -2162,7 +2163,7 @@ DBImpl::WaitCollectionIndexRecursively(const std::string& collection_id, const C status = meta_ptr_->UpdateCollectionFilesToIndex(collection_id); } - std::this_thread::sleep_for(std::chrono::seconds(WAIT_BUILD_INDEX_INTERVAL)); + index_req_swn_.Wait_For(std::chrono::seconds(WAIT_BUILD_INDEX_INTERVAL)); GetFilesToBuildIndex(collection_id, file_types, collection_files); ++times; diff --git a/core/src/db/DBImpl.h b/core/src/db/DBImpl.h index 4001326622..c68e8977b6 100644 --- a/core/src/db/DBImpl.h +++ b/core/src/db/DBImpl.h @@ -344,6 +344,7 @@ class DBImpl : public DB, public server::CacheConfigHandler, public server::Engi SimpleWaitNotify swn_index_; SimpleWaitNotify flush_req_swn_; + SimpleWaitNotify index_req_swn_; ThreadPool merge_thread_pool_; std::mutex merge_result_mutex_;