mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 09:08:43 +08:00
fix: avoid potential race conditions when updating the executor (#45230)
issue: #43040 Signed-off-by: Shawn Wang <shawn.wang@zilliz.com>
This commit is contained in:
parent
ab11fddc66
commit
40b5e6b134
@ -359,15 +359,16 @@ class FileWriteWorkerPool {
|
||||
|
||||
bool
|
||||
AddTask(std::function<void()> task) {
|
||||
std::lock_guard<std::mutex> lock(executor_mutex_);
|
||||
if (executor_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(executor_mutex_);
|
||||
executor_->add(std::move(task));
|
||||
return true;
|
||||
}
|
||||
|
||||
~FileWriteWorkerPool() {
|
||||
std::lock_guard<std::mutex> lock(executor_mutex_);
|
||||
if (executor_ != nullptr) {
|
||||
executor_->stop();
|
||||
executor_->join();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user