mirror of
https://github.com/neovim/neovim.git
synced 2025-11-12 05:18:52 +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:
@@ -61,9 +61,13 @@
|
||||
#include "nvim/os/input.h"
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/os/time.h"
|
||||
#include "nvim/os/event.h"
|
||||
#include "nvim/event/loop.h"
|
||||
#include "nvim/os/signal.h"
|
||||
#include "nvim/os/job.h"
|
||||
#include "nvim/msgpack_rpc/defs.h"
|
||||
#include "nvim/msgpack_rpc/helpers.h"
|
||||
#include "nvim/msgpack_rpc/server.h"
|
||||
#include "nvim/msgpack_rpc/channel.h"
|
||||
#include "nvim/api/private/defs.h"
|
||||
#include "nvim/api/private/helpers.h"
|
||||
#include "nvim/api/private/handle.h"
|
||||
@@ -133,6 +137,42 @@ static const char *err_extra_cmd =
|
||||
N_("Too many \"+command\", \"-c command\" or \"--cmd command\" arguments");
|
||||
|
||||
|
||||
void event_init(void)
|
||||
{
|
||||
loop_init(&loop, NULL);
|
||||
// early msgpack-rpc initialization
|
||||
msgpack_rpc_init_method_table();
|
||||
msgpack_rpc_helpers_init();
|
||||
// Initialize input events
|
||||
input_init();
|
||||
// Timer to wake the event loop if a timeout argument is passed to
|
||||
// `event_poll`
|
||||
// Signals
|
||||
signal_init();
|
||||
job_init();
|
||||
// finish mspgack-rpc initialization
|
||||
channel_init();
|
||||
server_init();
|
||||
terminal_init();
|
||||
}
|
||||
|
||||
void event_teardown(void)
|
||||
{
|
||||
if (!loop.deferred_events) {
|
||||
return;
|
||||
}
|
||||
|
||||
loop_process_all_events(&loop);
|
||||
input_stop();
|
||||
channel_teardown();
|
||||
job_teardown();
|
||||
server_teardown();
|
||||
signal_teardown();
|
||||
terminal_teardown();
|
||||
|
||||
loop_close(&loop);
|
||||
}
|
||||
|
||||
/// Performs early initialization.
|
||||
///
|
||||
/// Needed for unit tests. Must be called after `time_init()`.
|
||||
|
||||
Reference in New Issue
Block a user