mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 10:08:42 +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
|
bool
|
||||||
AddTask(std::function<void()> task) {
|
AddTask(std::function<void()> task) {
|
||||||
|
std::lock_guard<std::mutex> lock(executor_mutex_);
|
||||||
if (executor_ == nullptr) {
|
if (executor_ == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::lock_guard<std::mutex> lock(executor_mutex_);
|
|
||||||
executor_->add(std::move(task));
|
executor_->add(std::move(task));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
~FileWriteWorkerPool() {
|
~FileWriteWorkerPool() {
|
||||||
|
std::lock_guard<std::mutex> lock(executor_mutex_);
|
||||||
if (executor_ != nullptr) {
|
if (executor_ != nullptr) {
|
||||||
executor_->stop();
|
executor_->stop();
|
||||||
executor_->join();
|
executor_->join();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user