mirror of
https://github.com/openharmony/miscservices_time.git
synced 2026-07-18 17:34:34 -04:00
@@ -93,6 +93,7 @@ private:
|
||||
std::chrono::steady_clock::time_point ConvertToElapsed(std::chrono::milliseconds when, int type);
|
||||
std::chrono::steady_clock::time_point GetBootTimeNs();
|
||||
void CallbackAlarmIfNeed(std::shared_ptr<TimerInfo> alarm);
|
||||
bool StopTimerInner(uint64_t timerNumber, bool needDestroy);
|
||||
void RemoveProxy(uint64_t timerNumber, int32_t uid);
|
||||
|
||||
std::map<uint64_t, std::shared_ptr<TimerEntry>> timerEntryMap_;
|
||||
|
||||
@@ -126,23 +126,15 @@ bool TimerManager::StartTimer(uint64_t timerNumber, uint64_t triggerTime)
|
||||
|
||||
bool TimerManager::StopTimer(uint64_t timerNumber)
|
||||
{
|
||||
TIME_HILOGD(TIME_MODULE_SERVICE, "start.");
|
||||
std::lock_guard<std::mutex> lock(entryMapMutex_);
|
||||
auto it = timerEntryMap_.find(timerNumber);
|
||||
if (it == timerEntryMap_.end()) {
|
||||
TIME_HILOGD(TIME_MODULE_SERVICE, "end.");
|
||||
return false;
|
||||
}
|
||||
RemoveHandler(timerNumber);
|
||||
if (it->second) {
|
||||
int32_t uid = it->second->uid;
|
||||
RemoveProxy(timerNumber, uid);
|
||||
}
|
||||
TIME_HILOGD(TIME_MODULE_SERVICE, "end.");
|
||||
return true;
|
||||
return StopTimerInner(timerNumber, false);
|
||||
}
|
||||
|
||||
bool TimerManager::DestroyTimer(uint64_t timerNumber)
|
||||
{
|
||||
return StopTimerInner(timerNumber, true);
|
||||
}
|
||||
|
||||
bool TimerManager::StopTimerInner(uint64_t timerNumber, bool needDestroy)
|
||||
{
|
||||
TIME_HILOGD(TIME_MODULE_SERVICE, "start id: %{public}" PRId64 "", timerNumber);
|
||||
std::lock_guard<std::mutex> lock(entryMapMutex_);
|
||||
@@ -156,7 +148,9 @@ bool TimerManager::DestroyTimer(uint64_t timerNumber)
|
||||
int32_t uid = it->second->uid;
|
||||
RemoveProxy(timerNumber, uid);
|
||||
}
|
||||
timerEntryMap_.erase(it);
|
||||
if (needDestroy) {
|
||||
timerEntryMap_.erase(it);
|
||||
}
|
||||
TIME_HILOGD(TIME_MODULE_SERVICE, "end.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user