mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 11:26:37 +00:00
msgpack: Replace FUNC_ATTR_DEFERRED by FUNC_ATTR_ASYNC
API functions exposed via msgpack-rpc now fall into two categories: - async functions, which are executed as soon as the request is parsed - sync functions, which are invoked in nvim main loop when processing the `K_EVENT special key Only a few functions which can be safely executed in any context are marked as async.
This commit is contained in:
@@ -450,16 +450,16 @@ static void handle_request(Channel *channel, msgpack_object *request)
|
||||
method->via.bin.size);
|
||||
} else {
|
||||
handler.fn = msgpack_rpc_handle_missing_method;
|
||||
handler.defer = false;
|
||||
handler.async = true;
|
||||
}
|
||||
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
if (!msgpack_rpc_to_array(msgpack_rpc_args(request), &args)) {
|
||||
handler.fn = msgpack_rpc_handle_invalid_arguments;
|
||||
handler.defer = false;
|
||||
handler.async = true;
|
||||
}
|
||||
|
||||
bool defer = (!kv_size(channel->call_stack) && handler.defer);
|
||||
bool async = kv_size(channel->call_stack) || handler.async;
|
||||
RequestEvent *event_data = xmalloc(sizeof(RequestEvent));
|
||||
event_data->channel = channel;
|
||||
event_data->handler = handler;
|
||||
@@ -469,7 +469,7 @@ static void handle_request(Channel *channel, msgpack_object *request)
|
||||
loop_push_event(&loop, (Event) {
|
||||
.handler = on_request_event,
|
||||
.data = event_data
|
||||
}, defer);
|
||||
}, !async);
|
||||
}
|
||||
|
||||
static void on_request_event(Event event)
|
||||
|
Reference in New Issue
Block a user