reduce timer

Change-Id: Ia955b763bf486c99a4d11308473ae7b0cdffeabf
Signed-off-by: louzhihao <louzhihao@huawei.com>
This commit is contained in:
louzhihao 2024-11-14 20:07:26 +08:00
parent 5a1a173b4f
commit 2fc775fa0c
5 changed files with 9 additions and 7 deletions

View File

@ -91,7 +91,7 @@ void SchedulerManager::DestoryTimerTask(int64_t timerId)
void SchedulerManager::ResetTimerTask(int64_t timerId, int64_t reminderTime)
{
TimeServiceClient::GetInstance()->StopTimer(timerId);
// This start also means reset, new one will replace old one
TimeServiceClient::GetInstance()->StartTimer(timerId, static_cast<uint64_t>(reminderTime));
}

View File

@ -216,7 +216,7 @@ int32_t DataShareServiceImpl::AddTemplate(const std::string &uri, const int64_t
return templateStrategy_.Execute(context, [&uri, &tpltId, &tplt, &context]() -> int32_t {
auto result = TemplateManager::GetInstance().Add(
Key(uri, tpltId.subscriberId_, tpltId.bundleName_), context->currentUserId, tplt);
RdbSubscriberManager::GetInstance().Emit(context->uri, tpltId.subscriberId_, context);
RdbSubscriberManager::GetInstance().Emit(context->uri, tpltId.subscriberId_, tpltId.bundleName_, context);
return result;
});
}

View File

@ -359,7 +359,7 @@ void RdbSubscriberManager::Clear()
rdbCache_.Clear();
}
void RdbSubscriberManager::Emit(const std::string &uri, int64_t subscriberId, std::shared_ptr<Context> context)
void RdbSubscriberManager::Emit(const std::string &uri, int64_t subscriberId, const std::string &bundleName, std::shared_ptr<Context> context)
{
if (!URIUtils::IsDataProxyURI(uri)) {
return;
@ -376,8 +376,9 @@ void RdbSubscriberManager::Emit(const std::string &uri, int64_t subscriberId, st
SetObserverNotifyOnEnabled(val);
return false;
});
SchedulerManager::GetInstance().Execute(
uri, context->currentUserId, context->calledSourceDir, context->version, context->calledBundleName);
Key executeKey(uri, subscriberId, bundleName);
SchedulerManager::GetInstance().Execute(executeKey, context->currentUserId,
context->calledSourceDir, context->version);
}
RdbSubscriberManager::ObserverNode::ObserverNode(const sptr<IDataProxyRdbObserver> &observer,
uint32_t firstCallerTokenId, uint32_t callerTokenId)

View File

@ -61,7 +61,8 @@ public:
void Delete(uint32_t callerTokenId);
int Disable(const Key &key, uint32_t firstCallerTokenId);
int Enable(const Key &key, std::shared_ptr<Context> context);
void Emit(const std::string &uri, int64_t subscriberId, std::shared_ptr<Context> context);
void Emit(const std::string &uri, int64_t subscriberId, const std::string &bundleName,
std::shared_ptr<Context> context);
void Emit(const std::string &uri, std::shared_ptr<Context> context);
void Emit(const std::string &uri, int32_t userId, DistributedData::StoreMetaData &metaData);
void EmitByKey(const Key &key, int32_t userId, const std::string &rdbPath, int version);

View File

@ -178,7 +178,7 @@ HWTEST_F(DataShareSubscriberManagersTest, Emit, TestSize.Level1)
{
auto context = std::make_shared<Context>(DATA_SHARE_URI_TEST);
RdbSubscriberManager::GetInstance().Emit(DATA_SHARE_URI_TEST, context);
RdbSubscriberManager::GetInstance().Emit(DATA_SHARE_URI_TEST, TEST_SUB_ID, context);
RdbSubscriberManager::GetInstance().Emit(DATA_SHARE_URI_TEST, TEST_SUB_ID, BUNDLE_NAME_TEST, context);
TemplateId tpltId;
tpltId.subscriberId_ = TEST_SUB_ID;
tpltId.bundleName_ = BUNDLE_NAME_TEST;