aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/event
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-05-25 11:00:54 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2016-05-25 11:00:54 +0200
commitc74ce334f2f7c42dcd33bc5a0d1cc02b752733f6 (patch)
tree0c1696f84e8ff072709f843726fdedcb3c6cd48d /src/nvim/event
parent1e22076a6561ae2dba820ff961795ddb571940ea (diff)
parent5cc87d4dabd02167117be7a978b5c8faaa975419 (diff)
downloadrneovim-c74ce334f2f7c42dcd33bc5a0d1cc02b752733f6.tar.gz
rneovim-c74ce334f2f7c42dcd33bc5a0d1cc02b752733f6.tar.bz2
rneovim-c74ce334f2f7c42dcd33bc5a0d1cc02b752733f6.zip
Merge pull request #4624 from bfredl/timers
implement timers and process events during sleep
Diffstat (limited to 'src/nvim/event')
-rw-r--r--src/nvim/event/time.c5
-rw-r--r--src/nvim/event/time.h1
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