diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2021-06-22 15:18:19 +0300 |
---|---|---|
committer | avih <avih@users.noreply.github.com> | 2021-06-23 23:47:08 +0300 |
commit | f73814b180ad4616ac1d21a729eb9dda4af040cc (patch) | |
tree | ca4eadfc605d460e46eac22185274a41e494ccd6 /player/configfiles.c | |
parent | 11423acf3048445620bf1e8987b3f7aa04887cf0 (diff) | |
download | mpv-f73814b180ad4616ac1d21a729eb9dda4af040cc.tar.bz2 mpv-f73814b180ad4616ac1d21a729eb9dda4af040cc.tar.xz |
lua: timers: don't block forever with slow callbacks
Previously, process_timers() kept going as long as there were due
timers, which could be for extended periods of time or even forever
if there were slow timer callbacks with either periodic timers or if
timers were added repeatedly.
This prevented dequeuing mpv events, and subsequently, among others,
prevented mpv from quitting until process_timers() completed.
For instance, this caused process_timers() to never return:
function render() <longer than 1/60 s on a slow system> end
mp.add_periodic_timer(1/60, render)
Similarly, it never returned if a timer callback always added a new
one-shot which was already due by the time the callback completed.
This commit ensures that process_timers() only executes callbacks which
were due when it started, so that timers which are added (or repeated)
during process_timers() will wait for the next iteration - after mpv
events are dequeued.
This has no performance impact under normal conditions (when callbacks
complete before the next timer is due).
Additionally, previously idle-observers were executed unconditionally
after the timers because indeed there was nothing due when (if...)
process_timers() completed. However, now process_timers() can return
even if there are due timers, so skip idle-observers on such case.
Diffstat (limited to 'player/configfiles.c')
0 files changed, 0 insertions, 0 deletions