mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
doc: eventloop
This commit is contained in:
@@ -59,7 +59,13 @@ void loop_poll_events(Loop *loop, int ms)
|
|||||||
multiqueue_process_events(loop->fast_events);
|
multiqueue_process_events(loop->fast_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schedule an event from another thread
|
/// Schedules an event from another thread.
|
||||||
|
///
|
||||||
|
/// @note Event is queued into `fast_events`, which is processed outside of the
|
||||||
|
/// primary `events` queue by loop_poll_events(). For `main_loop`, that
|
||||||
|
/// means `fast_events` is NOT processed in an "editor mode"
|
||||||
|
/// (VimState.execute), so redraw and other side-effects are likely to be
|
||||||
|
/// skipped.
|
||||||
void loop_schedule(Loop *loop, Event event)
|
void loop_schedule(Loop *loop, Event event)
|
||||||
{
|
{
|
||||||
uv_mutex_lock(&loop->mutex);
|
uv_mutex_lock(&loop->mutex);
|
||||||
|
@@ -16,10 +16,28 @@ KLIST_INIT(WatcherPtr, WatcherPtr, _noop)
|
|||||||
|
|
||||||
typedef struct loop {
|
typedef struct loop {
|
||||||
uv_loop_t uv;
|
uv_loop_t uv;
|
||||||
MultiQueue *events, *fast_events, *thread_events;
|
MultiQueue *events;
|
||||||
|
MultiQueue *thread_events;
|
||||||
|
// Immediate events:
|
||||||
|
// "Events that should be processed after exiting uv_run() (to avoid
|
||||||
|
// recursion), but before returning from loop_poll_events()."
|
||||||
|
// 502aee690c980fcb3cfcb3f211dcfad06103db46
|
||||||
|
// Practical consequence: these events are processed by
|
||||||
|
// state_enter()..os_inchar()
|
||||||
|
// whereas "regular" (main_loop.events) events are processed by
|
||||||
|
// state_enter()..VimState.execute()
|
||||||
|
// But state_enter()..os_inchar() can be "too early" if you want the event
|
||||||
|
// to trigger UI updates and other user-activity-related side-effects.
|
||||||
|
MultiQueue *fast_events;
|
||||||
|
|
||||||
|
// used by process/job-control subsystem
|
||||||
klist_t(WatcherPtr) *children;
|
klist_t(WatcherPtr) *children;
|
||||||
uv_signal_t children_watcher;
|
uv_signal_t children_watcher;
|
||||||
uv_timer_t children_kill_timer, poll_timer;
|
uv_timer_t children_kill_timer;
|
||||||
|
|
||||||
|
// generic timer, used by loop_poll_events()
|
||||||
|
uv_timer_t poll_timer;
|
||||||
|
|
||||||
size_t children_stop_requests;
|
size_t children_stop_requests;
|
||||||
uv_async_t async;
|
uv_async_t async;
|
||||||
uv_mutex_t mutex;
|
uv_mutex_t mutex;
|
||||||
|
@@ -49,11 +49,13 @@ getkey:
|
|||||||
ui_flush();
|
ui_flush();
|
||||||
// Call `os_inchar` directly to block for events or user input without
|
// Call `os_inchar` directly to block for events or user input without
|
||||||
// consuming anything from `input_buffer`(os/input.c) or calling the
|
// consuming anything from `input_buffer`(os/input.c) or calling the
|
||||||
// mapping engine. If an event was put into the queue, we send K_EVENT
|
// mapping engine.
|
||||||
// directly.
|
|
||||||
(void)os_inchar(NULL, 0, -1, 0);
|
(void)os_inchar(NULL, 0, -1, 0);
|
||||||
input_disable_events();
|
input_disable_events();
|
||||||
key = !multiqueue_empty(main_loop.events) ? K_EVENT : safe_vgetc();
|
// If an event was put into the queue, we send K_EVENT directly.
|
||||||
|
key = !multiqueue_empty(main_loop.events)
|
||||||
|
? K_EVENT
|
||||||
|
: safe_vgetc();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == K_EVENT) {
|
if (key == K_EVENT) {
|
||||||
|
Reference in New Issue
Block a user