From b527ac752fd5ebcc74c06306e7009e2b98e4ee01 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Mon, 20 Oct 2014 10:39:54 -0300 Subject: event: Extract event_poll loops to `event_poll_until` macro A pattern that is becoming common across the project is to poll for events until a certain condition is true, optionally passing a timeout. To address this scenario, the event_poll_until macro was created and the job/channel/input modules were refactored to use it on their blocking functions. --- src/nvim/os/event.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/nvim/os/event.c') diff --git a/src/nvim/os/event.c b/src/nvim/os/event.c index 00920fc5cf..2dee529452 100644 --- a/src/nvim/os/event.c +++ b/src/nvim/os/event.c @@ -27,7 +27,7 @@ KLIST_INIT(Event, Event, _destroy_event) typedef struct { bool timed_out; - int32_t ms; + int ms; uv_timer_t *timer; } TimerData; @@ -66,7 +66,7 @@ void event_teardown(void) } // Wait for some event -bool event_poll(int32_t ms) +void event_poll(int ms) { uv_run_mode run_mode = UV_RUN_ONCE; @@ -111,8 +111,6 @@ bool event_poll(int32_t ms) uv_close((uv_handle_t *)&timer_prepare, NULL); loop(UV_RUN_NOWAIT); } - - return !timer_data.timed_out && event_has_deferred(); } bool event_has_deferred(void) -- cgit