diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2016-04-21 17:06:03 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2016-05-24 22:08:56 +0200 |
commit | 61e8adb25e6f37c3c9df0dd8f4fea5e23b62bacd (patch) | |
tree | 8b9d3e2d2f4f6c83d6c513b35c56a11e86c921fe /src/nvim/event | |
parent | 176f223ea3d1e8fb5716d5c2c0f09bead4864d59 (diff) | |
download | rneovim-61e8adb25e6f37c3c9df0dd8f4fea5e23b62bacd.tar.gz rneovim-61e8adb25e6f37c3c9df0dd8f4fea5e23b62bacd.tar.bz2 rneovim-61e8adb25e6f37c3c9df0dd8f4fea5e23b62bacd.zip |
eval: implement timers. vim-patch: 7.4.1578, 7.4.1831
For the moment, timers are triggered during sleep,
but not in wait-for-input modes, like press-RETURN or f_getchar()
Diffstat (limited to 'src/nvim/event')
-rw-r--r-- | src/nvim/event/time.c | 5 | ||||
-rw-r--r-- | src/nvim/event/time.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/event/time.c b/src/nvim/event/time.c index 7bf333bcea..f68a66345f 100644 --- a/src/nvim/event/time.c +++ b/src/nvim/event/time.c @@ -17,6 +17,7 @@ void time_watcher_init(Loop *loop, TimeWatcher *watcher, void *data) watcher->uv.data = watcher; watcher->data = data; watcher->events = loop->fast_events; + watcher->blockable = false; } void time_watcher_start(TimeWatcher *watcher, time_cb cb, uint64_t timeout, @@ -50,6 +51,10 @@ static void time_watcher_cb(uv_timer_t *handle) FUNC_ATTR_NONNULL_ALL { TimeWatcher *watcher = handle->data; + if (watcher->blockable && !queue_empty(watcher->events)) { + // the timer blocked and there already is an unprocessed event waiting + return; + } CREATE_EVENT(watcher->events, time_event, 1, watcher); } diff --git a/src/nvim/event/time.h b/src/nvim/event/time.h index 7882b2b627..14df176ea3 100644 --- a/src/nvim/event/time.h +++ b/src/nvim/event/time.h @@ -13,6 +13,7 @@ struct time_watcher { void *data; time_cb cb, close_cb; Queue *events; + bool blockable; }; #ifdef INCLUDE_GENERATED_DECLARATIONS |