From 3bb125bf905378ede8e134e837b475684f2ca339 Mon Sep 17 00:00:00 2001 From: zhangjunxi Date: Sat, 2 Jul 2022 11:01:52 +0800 Subject: [PATCH] Signed-off-by: zhangjunxi Changes to be committed: modified: timer/src/timer_handler.cpp modified: timer/src/timer_manager.cpp --- services/timer/src/timer_handler.cpp | 1 - services/timer/src/timer_manager.cpp | 26 +------------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/services/timer/src/timer_handler.cpp b/services/timer/src/timer_handler.cpp index dad2e78..c9b8988 100644 --- a/services/timer/src/timer_handler.cpp +++ b/services/timer/src/timer_handler.cpp @@ -104,7 +104,6 @@ TimerHandler::~TimerHandler() int TimerHandler::Set(uint32_t type, std::chrono::nanoseconds when) { - TIME_HILOGI(TIME_MODULE_SERVICE, "type= %{public}d, when= %{public}lld", type, when.count()); if (static_cast(type) > ALARM_TYPE_COUNT) { errno = EINVAL; return -1; diff --git a/services/timer/src/timer_manager.cpp b/services/timer/src/timer_manager.cpp index 0d7afa7..ef2995d 100644 --- a/services/timer/src/timer_manager.cpp +++ b/services/timer/src/timer_manager.cpp @@ -363,17 +363,14 @@ void TimerManager::TimerLooper() do { result = handler_->WaitForAlarm(); } while (result < 0 && errno == EINTR); - TIME_HILOGI(TIME_MODULE_SERVICE, "result= %{public}d", result); auto nowRtc = std::chrono::system_clock::now(); auto nowElapsed = GetBootTimeNs(); triggerList.clear(); if ((result & TIME_CHANGED_MASK) != 0) { - TIME_HILOGI(TIME_MODULE_SERVICE, "time changed"); system_clock::time_point lastTimeChangeClockTime; system_clock::time_point expectedClockTime; - TIME_HILOGI(TIME_MODULE_SERVICE, "lock"); std::lock_guard lock(mutex_); lastTimeChangeClockTime = lastTimeChangeClockTime_; expectedClockTime = lastTimeChangeClockTime + (duration_cast(nowElapsed.time_since_epoch()) - @@ -381,7 +378,6 @@ void TimerManager::TimerLooper() if (lastTimeChangeClockTime == system_clock::time_point::min() || nowRtc < (expectedClockTime - milliseconds(ONE_THOUSAND)) || nowRtc > (expectedClockTime + milliseconds(ONE_THOUSAND))) { - TIME_HILOGI(TIME_MODULE_SERVICE, "Time changed notification from kernel; rebatching"); ReBatchAllTimers(); lastTimeChangeClockTime_ = nowRtc; lastTimeChangeRealtime_ = nowElapsed; @@ -390,8 +386,7 @@ void TimerManager::TimerLooper() if (result != TIME_CHANGED_MASK) { std::lock_guard lock(mutex_); - auto hasWakeup = TriggerTimersLocked(triggerList, nowElapsed); - TIME_HILOGI(TIME_MODULE_SERVICE, "hasWakeup= %{public}d", hasWakeup); + TriggerTimersLocked(triggerList, nowElapsed); DeliverTimersLocked(triggerList, nowElapsed); RescheduleKernelTimerLocked(); } else { @@ -423,17 +418,10 @@ steady_clock::time_point TimerManager::GetBootTimeNs() bool TimerManager::TriggerTimersLocked(std::vector> &triggerList, std::chrono::steady_clock::time_point nowElapsed) { - TIME_HILOGI(TIME_MODULE_SERVICE, "alarmBatches_.size= %{public}d", static_cast(alarmBatches_.size())); bool hasWakeup = false; while (!alarmBatches_.empty()) { auto batch = alarmBatches_.at(0); - TIME_HILOGI(TIME_MODULE_SERVICE, "batch->GetStart()= %{public}lld", - time_point_cast(batch->GetStart()).time_since_epoch().count()); - TIME_HILOGI(TIME_MODULE_SERVICE, "nowElapsed= %{public}lld", - time_point_cast(nowElapsed).time_since_epoch().count()); if (batch->GetStart() > nowElapsed) { - TIME_HILOGI(TIME_MODULE_SERVICE, "break alarmBatches_.size= %{public}d", - static_cast(alarmBatches_.size())); break; } alarmBatches_.erase(alarmBatches_.begin()); @@ -471,23 +459,16 @@ bool TimerManager::TriggerTimersLocked(std::vector> & void TimerManager::RescheduleKernelTimerLocked() { - TIME_HILOGI(TIME_MODULE_SERVICE, "start alarmBatches_.size= %{public}d", static_cast(alarmBatches_.size())); auto nextNonWakeup = std::chrono::steady_clock::time_point::min(); if (!alarmBatches_.empty()) { auto firstWakeup = FindFirstWakeupBatchLocked(); auto firstBatch = alarmBatches_.front(); if (firstWakeup != nullptr) { auto alarmPtr = firstWakeup->Get(0); - if (alarmPtr != nullptr) { - TIME_HILOGI(TIME_MODULE_SERVICE, "wake up alarm id :%{public}" PRId64 "", alarmPtr->id); - } SetLocked(ELAPSED_REALTIME_WAKEUP, firstWakeup->GetStart().time_since_epoch()); } if (firstBatch != firstWakeup) { auto alarmPtr = firstBatch->Get(0); - if (alarmPtr != nullptr) { - TIME_HILOGI(TIME_MODULE_SERVICE, "nonwakeup alarm id :%{public}" PRId64 "", alarmPtr->id); - } nextNonWakeup = firstBatch->GetStart(); } } @@ -495,7 +476,6 @@ void TimerManager::RescheduleKernelTimerLocked() if (nextNonWakeup != std::chrono::steady_clock::time_point::min()) { SetLocked(ELAPSED_REALTIME, nextNonWakeup.time_since_epoch()); } - TIME_HILOGI(TIME_MODULE_SERVICE, "end"); } std::shared_ptr TimerManager::FindFirstWakeupBatchLocked() @@ -510,9 +490,7 @@ std::shared_ptr TimerManager::FindFirstWakeupBatchLocked() void TimerManager::SetLocked(int type, std::chrono::nanoseconds when) { - TIME_HILOGI(TIME_MODULE_SERVICE, "start when.count= %{public}lld", when.count()); handler_->Set(static_cast(type), when); - TIME_HILOGI(TIME_MODULE_SERVICE, "end"); } void TimerManager::InsertAndBatchTimerLocked(std::shared_ptr alarm) @@ -549,14 +527,12 @@ int64_t TimerManager::AttemptCoalesceLocked(std::chrono::steady_clock::time_poin void TimerManager::DeliverTimersLocked(const std::vector> &triggerList, std::chrono::steady_clock::time_point nowElapsed) { - TIME_HILOGI(TIME_MODULE_SERVICE, "start"); for (const auto &alarm : triggerList) { if (alarm->callback) { alarm->callback(alarm->id); TIME_HILOGI(TIME_MODULE_SERVICE, "Trigger id: %{public}" PRId64 "", alarm->id); } } - TIME_HILOGI(TIME_MODULE_SERVICE, "end"); } bool AddBatchLocked(std::vector> &list, const std::shared_ptr &newBatch)