diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-07-17 00:46:34 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-07-17 00:46:34 -0300 |
commit | 883b78d29864f39b8032468c4374766dad7d142f (patch) | |
tree | b555f3a48c08862c07ef7518a8ba6c8fa58c1aee /src/nvim/main.c | |
parent | d88c93acf390ea9d5e8674283927cff60fb41e0d (diff) | |
parent | aa9cb48bf08af14068178619414590254b263882 (diff) | |
download | rneovim-883b78d29864f39b8032468c4374766dad7d142f.tar.gz rneovim-883b78d29864f39b8032468c4374766dad7d142f.tar.bz2 rneovim-883b78d29864f39b8032468c4374766dad7d142f.zip |
Merge PR #2980 'Refactor event loop layer'
Helped-by: oni-link <knil.ino@gmail.com>
Reviewed-by: oni-link <knil.ino@gmail.com>
Reviewed-by: Scott Prager <splinterofchaos@gmail.com>
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r-- | src/nvim/main.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index 50c16c51d6..e2ae63e134 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -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/event/process.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,41 @@ 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(); + // 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(); + process_teardown(&loop); + server_teardown(); + signal_teardown(); + terminal_teardown(); + + loop_close(&loop); +} + /// Performs early initialization. /// /// Needed for unit tests. Must be called after `time_init()`. |