diff options
author | Thomas Wienecke <wienecke.t@gmail.com> | 2014-03-27 13:04:26 +0100 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-03-27 19:57:55 -0300 |
commit | 4e29a820b60148f2371cf0aba219712faba56a1f (patch) | |
tree | a8dd17cc6af8b578d98e5b9b11a97a7fd21e6e47 /src/os/event.c | |
parent | 5762c4e528cbd6629319bf3958d1f6554b399b20 (diff) | |
download | rneovim-4e29a820b60148f2371cf0aba219712faba56a1f.tar.gz rneovim-4e29a820b60148f2371cf0aba219712faba56a1f.tar.bz2 rneovim-4e29a820b60148f2371cf0aba219712faba56a1f.zip |
Address clint warnings and other style issues.
* Add const.
* Fix conditions (move && from end to start of line).
* Use int32_t instead of long.
* Use //-style comments.
Diffstat (limited to 'src/os/event.c')
-rw-r--r-- | src/os/event.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/src/os/event.c b/src/os/event.c index 798bf03946..eb7960c219 100644 --- a/src/os/event.c +++ b/src/os/event.c @@ -13,23 +13,23 @@ static void timer_prepare_cb(uv_prepare_t *, int); void event_init() { - /* Initialize input events */ + // Initialize input events input_init(); - /* Timer to wake the event loop if a timeout argument is passed to - * `event_poll` */ + // Timer to wake the event loop if a timeout argument is passed to + // `event_poll` uv_timer_init(uv_default_loop(), &timer); - /* This prepare handle that actually starts the timer */ + // This prepare handle that actually starts the timer uv_prepare_init(uv_default_loop(), &timer_prepare); } -/* Wait for some event */ +// Wait for some event bool event_poll(int32_t ms) { bool timed_out; uv_run_mode run_mode = UV_RUN_ONCE; if (input_ready()) { - /* If there's a pending input event to be consumed, do it now */ + // If there's a pending input event to be consumed, do it now return true; } @@ -37,42 +37,39 @@ bool event_poll(int32_t ms) timed_out = false; if (ms > 0) { - /* Timeout passed as argument to the timer */ + // Timeout passed as argument to the timer timer.data = &timed_out; - /* We only start the timer after the loop is running, for that we - * use an prepare handle(pass the interval as data to it) */ + // We only start the timer after the loop is running, for that we + // use an prepare handle(pass the interval as data to it) timer_prepare.data = &ms; uv_prepare_start(&timer_prepare, timer_prepare_cb); } else if (ms == 0) { - /* - * For ms == 0, we need to do a non-blocking event poll by - * setting the run mode to UV_RUN_NOWAIT. - */ + // For ms == 0, we need to do a non-blocking event poll by + // setting the run mode to UV_RUN_NOWAIT. run_mode = UV_RUN_NOWAIT; } do { - /* Run one event loop iteration, blocking for events if run_mode is - * UV_RUN_ONCE */ + // Run one event loop iteration, blocking for events if run_mode is + // UV_RUN_ONCE uv_run(uv_default_loop(), run_mode); } while ( - /* Continue running if ... */ - !input_ready() && /* ... we have no input */ - run_mode != UV_RUN_NOWAIT && /* ... ms != 0 */ - !timed_out /* ... we didn't get a timeout */ - ); + // Continue running if ... + !input_ready() // ... we have no input + && run_mode != UV_RUN_NOWAIT // ... ms != 0 + && !timed_out); // ... we didn't get a timeout input_stop(); if (ms > 0) { - /* Stop the timer */ + // Stop the timer uv_timer_stop(&timer); } return input_ready(); } -/* Set a flag in the `event_poll` loop for signaling of a timeout */ +// Set a flag in the `event_poll` loop for signaling of a timeout static void timer_cb(uv_timer_t *handle, int status) { *((bool *)handle->data) = true; |