fix(power): restart idle tasks from now#1169
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1. Reset the power save plan from the current time when the battery state changes. 2. Add a reset path that keeps full task delays while the session is already idle. 3. Preserve elapsed-idle checks only for the normal idle entry path. Log: Restart idle power save tasks from the current time after power source changes. fix(power): 修复 idle 任务重置 1. 电池状态变化时从当前时间重新重置节能计划。 2. 会话已处于 idle 状态时保留任务完整延迟重新调度。 3. 仅在正常进入 idle 流程时保留已 idle 时长检查。 Log: 电源状态变化后从当前时间重新调度 idle 节能任务。
Reviewer's GuideThis PR changes how idle power save tasks are reset when the power source (battery vs line power) changes: it adds a ResetFromNow path that recomputes delays from the current time, differentiates behavior when the session is already idle vs entering idle normally, and threads a new flag through the update and idle-task startup logic to control whether elapsed-idle checks are applied. Sequence diagram for updated idle power save reset behaviorsequenceDiagram
participant PowerOnBattery as power.OnBattery
participant PowerSavePlan as powerSavePlan
participant MetaTasks as metaTasks
PowerOnBattery->>PowerSavePlan: ResetFromNow()
PowerSavePlan->>PowerSavePlan: doUpdate(delays, shortIdleDelay, true)
alt psp.isIdle
PowerSavePlan->>MetaTasks: setRealDelayFromNow()
PowerSavePlan->>PowerSavePlan: startIdleTasksLocked(false)
else psp not idle
PowerSavePlan->>MetaTasks: setRealDelay(min)
end
actor IdleDetector
IdleDetector->>PowerSavePlan: HandleIdleOn()
PowerSavePlan->>PowerSavePlan: startIdleTasksLocked(true)
opt [useElapsedIdle && !UseWayland]
PowerSavePlan->>PowerSavePlan: shouldPreventIdle()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
7b7b1f3 to
3440075
Compare
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider renaming
doUpdateand itsresetFromNowboolean flag to something more explicit (e.g.,updateWithResetMode(..., resetDelaysFromNow bool)), and/or adding a short comment, to clarify the behavioral difference for future maintainers. - The new
startIdleTasksLocked(useElapsedIdle bool)signature changes behavior significantly depending on the flag; adding a brief comment on the function or parameter explaining whenuseElapsedIdleshould be true vs false would make the intent clearer and reduce misuse.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider renaming `doUpdate` and its `resetFromNow` boolean flag to something more explicit (e.g., `updateWithResetMode(..., resetDelaysFromNow bool)`), and/or adding a short comment, to clarify the behavioral difference for future maintainers.
- The new `startIdleTasksLocked(useElapsedIdle bool)` signature changes behavior significantly depending on the flag; adding a brief comment on the function or parameter explaining when `useElapsedIdle` should be true vs false would make the intent clearer and reduce misuse.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // setRealDelayFromNow 设置从当前时刻开始的实际延迟,而非从系统空闲开始计算
func (mts metaTasks) setRealDelayFromNow() {
for idx := range mts {
t := &mts[idx]
t.realDelay = time.Second * time.Duration(t.delay)
}
} |
|
TAG Bot New tag: 6.1.100 |
Log: Restart idle power save tasks from the current time after power source changes.
fix(power): 修复 idle 任务重置
Log: 电源状态变化后从当前时间重新调度 idle 节能任务。
Summary by Sourcery
Restart idle power save tasks from the current time when power source changes, while preserving elapsed idle checks only for normal idle entry.
Bug Fixes: