aboutsummaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-03-27 13:35:36 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-03-27 17:36:32 -0300
commite995b2156778fb28f1fbcf29a97d3f7f531e7583 (patch)
tree9049279ccadfaf1a6d429a4e3a46f5410f78afe0 /src/os
parent1e8eb4e2c6f75b12d863e52ded56ccd48b5c8769 (diff)
downloadrneovim-e995b2156778fb28f1fbcf29a97d3f7f531e7583.tar.gz
rneovim-e995b2156778fb28f1fbcf29a97d3f7f531e7583.tar.bz2
rneovim-e995b2156778fb28f1fbcf29a97d3f7f531e7583.zip
Re-integrate FEAT_FILTERPIPE code
This feature was accidentally removed when doing the initial import from vim. It makes vim use pipes instead of temporary files for filtering buffers through shell commands. I found that this was missing when looking for references of SHELL_READ/SHELL_WRITE outside mch_call_shell`. When `mch_call_shell` is reimplemented on top of libuv process management facilities, pipes will always be used for communication with child processes so it makes sense to enable the feature permanently.
Diffstat (limited to 'src/os')
-rw-r--r--src/os/event.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/os/event.c b/src/os/event.c
index 0a7d2c096c..ce630d5318 100644
--- a/src/os/event.c
+++ b/src/os/event.c
@@ -6,8 +6,10 @@
#include "os/event.h"
#include "os/input.h"
-static uv_timer_t timer_req;
+static uv_timer_t timer;
+static uv_prepare_t timer_prepare;
static void timer_cb(uv_timer_t *handle, int);
+static void timer_prepare_cb(uv_prepare_t *, int);
void event_init()
{
@@ -15,7 +17,9 @@ void event_init()
input_init();
/* Timer to wake the event loop if a timeout argument is passed to
* `event_poll` */
- uv_timer_init(uv_default_loop(), &timer_req);
+ uv_timer_init(uv_default_loop(), &timer);
+ /* This prepare handle that actually starts the timer */
+ uv_prepare_init(uv_default_loop(), &timer_prepare);
}
/* Wait for some event */
@@ -33,10 +37,12 @@ bool event_poll(int32_t ms)
timed_out = false;
if (ms > 0) {
- /* Timeout passed as argument, start the libuv timer to wake us up and
- * set our local flag */
- timer_req.data = &timed_out;
- uv_timer_start(&timer_req, timer_cb, ms, 0);
+ /* 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) */
+ 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
@@ -58,10 +64,11 @@ bool event_poll(int32_t ms)
input_stop();
- if (!timed_out && ms > 0) {
+ if (ms > 0) {
/* Timer event did not trigger, stop the watcher since we no longer
* care about it */
- uv_timer_stop(&timer_req);
+ uv_timer_stop(&timer);
+ uv_prepare_stop(&timer_prepare);
}
return input_ready();
@@ -72,3 +79,8 @@ static void timer_cb(uv_timer_t *handle, int status)
{
*((bool *)handle->data) = true;
}
+
+static void timer_prepare_cb(uv_prepare_t *handle, int status)
+{
+ uv_timer_start(&timer, timer_cb, *(uint32_t *)handle->data, 0);
+}