fix(db): db destruction bug fix

Former-commit-id: d77e18e428bc43b2cc1316f0d77b6807192f6662
This commit is contained in:
Xu Peng 2019-05-08 13:58:16 +08:00
parent 4428d56670
commit 56ffd6bad3
3 changed files with 4 additions and 3 deletions

View File

@ -19,7 +19,6 @@ DB::~DB() {}
void DB::Open(const Options& options, DB** dbptr) {
*dbptr = nullptr;
/* *dbptr = new DBImpl<FaissExecutionEngine<IVFIndexTrait>>(options); */
*dbptr = DBFactory::Build(options);
return;
}

View File

@ -176,8 +176,7 @@ Status DBImpl<EngineT>::search(const std::string& group_id, size_t k, size_t nq,
template<typename EngineT>
void DBImpl<EngineT>::start_timer_task(int interval_) {
std::thread bg_task(&DBImpl<EngineT>::background_timer_task, this, interval_);
bg_task.detach();
bg_timer_thread_ = std::thread(&DBImpl<EngineT>::background_timer_task, this, interval_);
}
template<typename EngineT>
@ -403,6 +402,7 @@ DBImpl<EngineT>::~DBImpl() {
bg_build_index_finish_signal_.wait(lock);
}
}
bg_timer_thread_.join();
std::vector<std::string> ids;
_pMemMgr->serialize(ids);
_env->Stop();

View File

@ -87,6 +87,8 @@ private:
bool bg_build_index_started_;
std::condition_variable bg_build_index_finish_signal_;
std::thread bg_timer_thread_;
MetaPtr _pMeta;
MemManagerPtr _pMemMgr;