Closed Bug 476253 Opened 15 years ago Closed 15 years ago

Dynamically pick next polling time for IdleService (instead of polling every 5 sec)

Categories

(Core :: Widget, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: Mardak, Assigned: Mardak)

References

Details

(Keywords: fixed1.9.1)

Attachments

(1 file, 1 obsolete file)

We can save on unnecessary polls by looking at the expected next here->idle transition time instead of blindly polling every 5 seconds.

(FYI, I'm interested in having the nsIIdleService send an observerService notification, once-a-day-on-idle, which will send that notification when the user goes idle, but will send at most one of these in a 24 hour period. This will require a timer to be available all the time, so I figured it would be good to make the polling "interval" smarter.)
Attached patch v1 (obsolete) — Splinter Review
Keep the minimum polling time at 5 seconds, but if we don't need to poll frequently, just check once every 5 minutes. (Actually we would only really need to check when the next here->idle transition might occur, but this is in preparation for an always-around timer for the once-a-day-on-idle notification.)

Also store the required idle time in milliseconds to not need to calculate * 1000 every time we check away state.
Assignee: nobody → edilee
Status: NEW → ASSIGNED
Attachment #359887 - Flags: review?(roc)
Blocks: 476254
Comment on attachment 359887 [details] [diff] [review]
v1

-        {
             mTimer->Cancel();
-            mTimer = nsnull;
-        }

Please don't remove the {} around single statements. That's our coding style last I checked.
Attachment #359887 - Flags: superreview+
Attachment #359887 - Flags: review?(roc)
Attachment #359887 - Flags: review+
This is going to suck for IM and such applications, where the idle time is actually directly reflected by automatic UI changes or server interaction. I mean, I wouldn't want my instant messaging program to wait 5 minutes before realizing I was back at the machine. :-\

So I'm not sure this is the right thing to do. I realize I don't have a say in this, but I'm a bit confused what your arguments are as to why this is even possible (rather than why it'd be a perf improvement - obviously we could get an even bigger perf improvement if we only polled once a day, but obviously that would also defeat the point).
When expecting an idle->back transition, it'll poll at the current 5 seconds. Only if all listeners are waiting for back->idle transition will it poll at 5 minute intervals (or somewhere between 5sec and 5min, e.g., 3 minutes if the next idle listener is looking for idle in 3 more minutes.)
(In reply to comment #4)
> When expecting an idle->back transition, it'll poll at the current 5 seconds.
> Only if all listeners are waiting for back->idle transition will it poll at 5
> minute intervals (or somewhere between 5sec and 5min, e.g., 3 minutes if the
> next idle listener is looking for idle in 3 more minutes.)

Ah, sorry, that's me not reading the patch (I just woke up). Apologies, and yes, that sounds fine, thanks!
Attached patch v1.1Splinter Review
(In reply to comment #2)
> Please don't remove the {} around single statements.
Restored the {}s and added them to the new code.
Attachment #359887 - Attachment is obsolete: true
http://hg.mozilla.org/mozilla-central/rev/72d2e6acd6a1
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.2a1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: