mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
event loop: New abstraction layer with refactored time/signal API
- Add event loop abstraction module under src/nvim/event. The src/nvim/event/loop module replaces src/nvim/os/event - Remove direct dependency on libuv signal/timer API and use the new abstraction instead. - Replace all references to uv_default_loop() by &loop.uv, a new global variable that wraps libuv main event loop but allows the event loop functions to be reused in other contexts.
This commit is contained in:
@@ -180,14 +180,14 @@ int server_start(const char *endpoint)
|
||||
|
||||
if (server_type == kServerTypeTcp) {
|
||||
// Listen on tcp address/port
|
||||
uv_tcp_init(uv_default_loop(), &server->socket.tcp.handle);
|
||||
uv_tcp_init(&loop.uv, &server->socket.tcp.handle);
|
||||
result = uv_tcp_bind(&server->socket.tcp.handle,
|
||||
(const struct sockaddr *)&server->socket.tcp.addr,
|
||||
0);
|
||||
stream = (uv_stream_t *)&server->socket.tcp.handle;
|
||||
} else {
|
||||
// Listen on named pipe or unix socket
|
||||
uv_pipe_init(uv_default_loop(), &server->socket.pipe.handle, 0);
|
||||
uv_pipe_init(&loop.uv, &server->socket.pipe.handle, 0);
|
||||
result = uv_pipe_bind(&server->socket.pipe.handle, server->addr);
|
||||
stream = (uv_stream_t *)&server->socket.pipe.handle;
|
||||
}
|
||||
@@ -308,10 +308,10 @@ static void connection_cb(uv_stream_t *server, int status)
|
||||
|
||||
if (srv->type == kServerTypeTcp) {
|
||||
client = xmalloc(sizeof(uv_tcp_t));
|
||||
uv_tcp_init(uv_default_loop(), (uv_tcp_t *)client);
|
||||
uv_tcp_init(&loop.uv, (uv_tcp_t *)client);
|
||||
} else {
|
||||
client = xmalloc(sizeof(uv_pipe_t));
|
||||
uv_pipe_init(uv_default_loop(), (uv_pipe_t *)client, 0);
|
||||
uv_pipe_init(&loop.uv, (uv_pipe_t *)client, 0);
|
||||
}
|
||||
|
||||
result = uv_accept(server, client);
|
||||
|
Reference in New Issue
Block a user