codingteam / pacmacs.el

Pacman for Emacs
Other
91 stars 9 forks source link

Reschedule game timer each tick instead of repeating it #198

Open rexim opened 8 years ago

rexim commented 8 years ago

http://www.gnu.org/software/emacs/manual/html_node/elisp/Timers.html

A repeating timer nominally ought to run every repeat seconds, but remember that any invocation of a timer can be late. Lateness of one repetition has no effect on the scheduled time of the next repetition. For instance, if Emacs is busy computing for long enough to cover three scheduled repetitions of the timer, and then starts to wait, it will immediately call the timer function three times in immediate succession (presuming no other timers trigger before or between them). If you want a timer to run again no less than n seconds after the last invocation, don’t use the repeat argument. Instead, the timer function should explicitly reschedule the timer.

We should check if this approach will give us any benefits.

Minoru commented 8 years ago

Remember the problems you used to have with Pacmacs when your Jabber client displayed a notification about someone else's message? IIRC, you resolved them by leaving the conference room for the stream.

Well, maybe¹ it was because Emacs stopped calling timer's callback for a while, and then fired it a couple of times in a row; this might've corrupted the state of the game.

I believe the switch to new scheme (rescheduling) will protect the game from such problems, but I also think that overall, the effect will be unnoticeable.

¹ Dreaming up theories in GitHub comments is easier than actually going back to stream recordings and checking things. Sorry. I hereby pledge to make a substantial contribution to one of your projects (I do the choosing) if this theory of mine is proven to be false.