add ExtcutorPool and modify code

Signed-off-by: renjiecui <cuirenjie@huawei.com>
This commit is contained in:
renjiecui 2023-05-07 23:47:20 +08:00
parent f20ec7f9b3
commit 8217086302
3 changed files with 8 additions and 4 deletions

View File

@ -57,7 +57,8 @@ HWTEST_F(KvStoreDataServiceTest, RegisterClientDeathObserver001, TestSize.Level1
KvStoreDataService kvDataService;
Bootstrap::GetInstance().LoadComponents();
Bootstrap::GetInstance().LoadCheckers();
KvStoreMetaManager::GetInstance().InitMetaParameter(std::make_shared<ExecutorPool>(12, 5));
KvStoreMetaManager::GetInstance().BindExecutor(std::make_shared<ExecutorPool>(12, 5));
KvStoreMetaManager::GetInstance().InitMetaParameter();
Status status = kvDataService.RegisterClientDeathObserver(appId, new KvStoreClientDeathObserver());
EXPECT_EQ(status, Status::SUCCESS) << "RegisterClientDeathObserver failed";
}

View File

@ -41,7 +41,8 @@ public:
Bootstrap::GetInstance().LoadComponents();
Bootstrap::GetInstance().LoadDirectory();
Bootstrap::GetInstance().LoadCheckers();
KvStoreMetaManager::GetInstance().InitMetaParameter(executors);
KvStoreMetaManager::GetInstance().BindExecutor(executors);
KvStoreMetaManager::GetInstance().InitMetaParameter();
KvStoreMetaManager::GetInstance().InitMetaListener();
DeviceManagerAdapter::GetInstance().Init(executors);

View File

@ -232,8 +232,10 @@ std::shared_ptr<RdbSyncer> RdbServiceImpl::GetRdbSyncer(const RdbSyncerParam &pa
syncer = it->second;
if (!param.isEncrypt_ || param.password_.empty()) {
executors_->Remove(syncer->GetTimerId(), true);
auto timerId = executors_->Schedule(std::chrono::milliseconds(SYNCER_TIMEOUT), [this, syncer] { SyncerTimeout(syncer); });
syncer->SetTimerId(timerId );
auto timerId = executors_->Schedule(std::chrono::milliseconds(SYNCER_TIMEOUT), [this, syncer] {
SyncerTimeout(syncer);
});
syncer->SetTimerId(timerId);
return true;
}
syncers.erase(storeId);