aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/msgpack_rpc
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-04-27 13:54:54 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-04-28 19:20:09 +0200
commitf17a8185191b778960953508a5bf9b5f95b0560c (patch)
treeb9178ecb3594f45992fcb5ce5c1f0b670ff4b594 /src/nvim/msgpack_rpc
parentacfd2a2a29ae852ecc965ca888eb5049400bf39d (diff)
downloadrneovim-f17a8185191b778960953508a5bf9b5f95b0560c.tar.gz
rneovim-f17a8185191b778960953508a5bf9b5f95b0560c.tar.bz2
rneovim-f17a8185191b778960953508a5bf9b5f95b0560c.zip
api/nvim_get_mode: Use child-queue instead of "priority".
Diffstat (limited to 'src/nvim/msgpack_rpc')
-rw-r--r--src/nvim/msgpack_rpc/channel.c7
-rw-r--r--src/nvim/msgpack_rpc/channel.h5
2 files changed, 8 insertions, 4 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index 9e43924db1..911f2a6fa4 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -28,7 +28,6 @@
#include "nvim/map.h"
#include "nvim/log.h"
#include "nvim/misc1.h"
-#include "nvim/state.h"
#include "nvim/lib/kvec.h"
#include "nvim/os/input.h"
@@ -91,6 +90,7 @@ static msgpack_sbuffer out_buffer;
/// Initializes the module
void channel_init(void)
{
+ ch_before_blocking_events = multiqueue_new_child(main_loop.events);
channels = pmap_new(uint64_t)();
event_strings = pmap_new(cstr_t)();
msgpack_sbuffer_init(&out_buffer);
@@ -446,9 +446,8 @@ static void handle_request(Channel *channel, msgpack_object *request)
&& !strncmp("nvim_get_mode", method->via.bin.ptr, method->via.bin.size);
if (is_get_mode && !input_blocking()) {
- // Schedule on the main loop with special priority. #6247
- Event ev = event_create(kEvPriorityAsync, on_request_event, 1, evdata);
- multiqueue_put_event(channel->events, ev);
+ // Defer the event to a special queue used by os/input.c. #6247
+ multiqueue_put(ch_before_blocking_events, on_request_event, 1, evdata);
} else {
// Invoke immediately.
on_request_event((void **)&evdata);
diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h
index 0d92976d02..f8fe6f129b 100644
--- a/src/nvim/msgpack_rpc/channel.h
+++ b/src/nvim/msgpack_rpc/channel.h
@@ -11,6 +11,11 @@
#define METHOD_MAXLEN 512
+/// HACK: os/input.c drains this queue immediately before blocking for input.
+/// Events on this queue are async-safe, but they need the resolved state
+/// of os_inchar(), so they are processed "just-in-time".
+MultiQueue *ch_before_blocking_events;
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "msgpack_rpc/channel.h.generated.h"
#endif