diff options
| author | bfredl <bjorn.linse@gmail.com> | 2022-12-30 19:49:59 +0100 |
|---|---|---|
| committer | bfredl <bjorn.linse@gmail.com> | 2022-12-30 19:56:11 +0100 |
| commit | 09370eae7756b07bb8f1f116b690b22aec7ec563 (patch) | |
| tree | 2bd937bae9748d54cff50da0c091503b663fe997 /src/nvim/event | |
| parent | 4ace9e7e417fe26c8b73ff1d6042e6e4f3df9ebf (diff) | |
| download | rneovim-09370eae7756b07bb8f1f116b690b22aec7ec563.tar.gz rneovim-09370eae7756b07bb8f1f116b690b22aec7ec563.tar.bz2 rneovim-09370eae7756b07bb8f1f116b690b22aec7ec563.zip | |
refactor(sleep): simplify rube goldberg implementation of :sleep
As neovim does have event handling, we are checking for CTRL-C
all the time, not once per second.
Also, do_sleep() reimplements the same loop as
LOOP_PROCESS_EVENTS_UNTIL() already contains internally. Fix the latter
to use the right integer type, so we do not need the extra indirection.
Diffstat (limited to 'src/nvim/event')
| -rw-r--r-- | src/nvim/event/loop.c | 4 | ||||
| -rw-r--r-- | src/nvim/event/loop.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c index 934f5fc69a..ab2524c1a9 100644 --- a/src/nvim/event/loop.c +++ b/src/nvim/event/loop.c @@ -43,7 +43,7 @@ void loop_init(Loop *loop, void *data) /// @param once true: process at most one `Loop.uv` event. /// false: process until `ms` timeout (only has effect if `ms` > 0). /// @return true if `ms` > 0 and was reached -bool loop_uv_run(Loop *loop, int ms, bool once) +bool loop_uv_run(Loop *loop, int64_t ms, bool once) { if (loop->recursive++) { abort(); // Should not re-enter uv_run @@ -82,7 +82,7 @@ bool loop_uv_run(Loop *loop, int ms, bool once) /// > 0: timeout after `ms`. /// < 0: wait forever. /// @return true if `ms` > 0 and was reached -bool loop_poll_events(Loop *loop, int ms) +bool loop_poll_events(Loop *loop, int64_t ms) { bool timeout_expired = loop_uv_run(loop, ms, true); multiqueue_process_events(loop->fast_events); diff --git a/src/nvim/event/loop.h b/src/nvim/event/loop.h index c0bcda40ce..b2265a726d 100644 --- a/src/nvim/event/loop.h +++ b/src/nvim/event/loop.h @@ -58,7 +58,7 @@ typedef struct loop { // Poll for events until a condition or timeout #define LOOP_PROCESS_EVENTS_UNTIL(loop, multiqueue, timeout, condition) \ do { \ - int remaining = timeout; \ + int64_t remaining = timeout; \ uint64_t before = (remaining > 0) ? os_hrtime() : 0; \ while (!(condition)) { \ LOOP_PROCESS_EVENTS(loop, multiqueue, remaining); \ @@ -66,7 +66,7 @@ typedef struct loop { break; \ } else if (remaining > 0) { \ uint64_t now = os_hrtime(); \ - remaining -= (int)((now - before) / 1000000); \ + remaining -= (int64_t)((now - before) / 1000000); \ before = now; \ if (remaining <= 0) { \ break; \ |