aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/event/socket.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-08-07 22:54:02 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-08-13 08:49:38 -0300
commit502aee690c980fcb3cfcb3f211dcfad06103db46 (patch)
tree803dbcccaa874b78cbdfeacc74b7cc891e09f89a /src/nvim/event/socket.c
parenta6e0d35d2da3ee4270ddb712410ea0c8c55b0f0f (diff)
downloadrneovim-502aee690c980fcb3cfcb3f211dcfad06103db46.tar.gz
rneovim-502aee690c980fcb3cfcb3f211dcfad06103db46.tar.bz2
rneovim-502aee690c980fcb3cfcb3f211dcfad06103db46.zip
event: Refactor async event processing
- Improve the implementation of deferred/immediate events. - Use the new queue module to change how/when events are queued/processed by giving a private queue to each emitter. - Immediate events(which only exist to break uv_run recursion) are now represented in the `loop->fast_events` queue. - Events pushed to child queues are propagated to the event loop main queue and processed as K_EVENT keys.
Diffstat (limited to 'src/nvim/event/socket.c')
-rw-r--r--src/nvim/event/socket.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c
index 2a618d290d..347e464d25 100644
--- a/src/nvim/event/socket.c
+++ b/src/nvim/event/socket.c
@@ -77,6 +77,7 @@ void socket_watcher_init(Loop *loop, SocketWatcher *watcher,
watcher->stream->data = watcher;
watcher->cb = NULL;
watcher->close_cb = NULL;
+ watcher->events = NULL;
}
int socket_watcher_start(SocketWatcher *watcher, int backlog, socket_cb cb)
@@ -143,10 +144,18 @@ void socket_watcher_close(SocketWatcher *watcher, socket_close_cb cb)
uv_close((uv_handle_t *)watcher->stream, close_cb);
}
+static void connection_event(void **argv)
+{
+ SocketWatcher *watcher = argv[0];
+ int status = (int)(uintptr_t)(argv[1]);
+ watcher->cb(watcher, status, watcher->data);
+}
+
static void connection_cb(uv_stream_t *handle, int status)
{
SocketWatcher *watcher = handle->data;
- watcher->cb(watcher, status, watcher->data);
+ CREATE_EVENT(watcher->events, connection_event, 2, watcher,
+ (void *)(uintptr_t)status);
}
static void close_cb(uv_handle_t *handle)