!2417 reduce timer in addtemplate

Merge pull request !2417 from WoodenArrow/log
This commit is contained in:
openharmony_ci 2024-11-16 06:51:59 +00:00 committed by Gitee
commit 38d06c93cd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
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) 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)); 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 { return templateStrategy_.Execute(context, [&uri, &tpltId, &tplt, &context]() -> int32_t {
auto result = TemplateManager::GetInstance().Add( auto result = TemplateManager::GetInstance().Add(
Key(uri, tpltId.subscriberId_, tpltId.bundleName_), context->currentUserId, tplt); 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; return result;
}); });
} }

View File

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

View File

@ -61,7 +61,8 @@ public:
void Delete(uint32_t callerTokenId); void Delete(uint32_t callerTokenId);
int Disable(const Key &key, uint32_t firstCallerTokenId); int Disable(const Key &key, uint32_t firstCallerTokenId);
int Enable(const Key &key, std::shared_ptr<Context> context); 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, std::shared_ptr<Context> context);
void Emit(const std::string &uri, int32_t userId, DistributedData::StoreMetaData &metaData); 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); 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); 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, 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; TemplateId tpltId;
tpltId.subscriberId_ = TEST_SUB_ID; tpltId.subscriberId_ = TEST_SUB_ID;
tpltId.bundleName_ = BUNDLE_NAME_TEST; tpltId.bundleName_ = BUNDLE_NAME_TEST;