mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
event: Ensure the loop is stopped when a event is pushed.
This commit is contained in:
parent
b16c5bf5e6
commit
6f471fa4fc
@ -74,6 +74,10 @@ void event_teardown(void)
|
||||
|
||||
process_events_from(immediate_events);
|
||||
process_events_from(deferred_events);
|
||||
// reset the stop_flag to ensure `uv_run` below won't exit early. This hack
|
||||
// is required because the `process_events_from` above may call `event_push`
|
||||
// which will set the stop_flag to 1(uv_stop)
|
||||
uv_default_loop()->stop_flag = 0;
|
||||
input_stop_stdin();
|
||||
channel_teardown();
|
||||
job_teardown();
|
||||
@ -153,6 +157,12 @@ void event_disable_deferred(void)
|
||||
// Queue an event
|
||||
void event_push(Event event, bool deferred)
|
||||
{
|
||||
// Sometimes libuv will run pending callbacks(timer for example) before
|
||||
// blocking for a poll. If this happens and the callback pushes a event to one
|
||||
// of the queues, the event would only be processed after the poll
|
||||
// returns(user hits a key for example). To avoid this scenario, we call
|
||||
// uv_stop when a event is enqueued.
|
||||
uv_stop(uv_default_loop());
|
||||
*kl_pushp(Event, deferred ? deferred_events : immediate_events) = event;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user