mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
timer_pause: stop the timer resource (#8199)
If the timer isn't stopped, it still emits events which consume some CPU. Fix #8188
This commit is contained in:
parent
e54ff10d44
commit
f21867a15c
@ -16861,6 +16861,12 @@ static void f_timer_pause(typval_T *argvars, typval_T *unused, FunPtr fptr)
|
||||
int paused = (bool)tv_get_number(&argvars[1]);
|
||||
timer_T *timer = pmap_get(uint64_t)(timers, tv_get_number(&argvars[0]));
|
||||
if (timer != NULL) {
|
||||
if (!timer->paused && paused) {
|
||||
time_watcher_stop(&timer->tw);
|
||||
} else if (timer->paused && !paused) {
|
||||
time_watcher_start(&timer->tw, timer_due_cb, timer->timeout,
|
||||
timer->timeout);
|
||||
}
|
||||
timer->paused = paused;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ func Test_paused()
|
||||
let slept = WaitFor('g:val == 1')
|
||||
call assert_equal(1, g:val)
|
||||
if has('reltime')
|
||||
call assert_inrange(0, 60, slept)
|
||||
call assert_inrange(0, 100, slept)
|
||||
else
|
||||
call assert_inrange(0, 10, slept)
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user