mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
doc: eventloop
This commit is contained in:
parent
b6b6e4a96f
commit
46fdacc5b5
@ -59,7 +59,13 @@ void loop_poll_events(Loop *loop, int ms)
|
||||
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)
|
||||
{
|
||||
uv_mutex_lock(&loop->mutex);
|
||||
|
@ -16,10 +16,28 @@ KLIST_INIT(WatcherPtr, WatcherPtr, _noop)
|
||||
|
||||
typedef struct loop {
|
||||
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;
|
||||
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;
|
||||
uv_async_t async;
|
||||
uv_mutex_t mutex;
|
||||
|
@ -49,11 +49,13 @@ getkey:
|
||||
ui_flush();
|
||||
// Call `os_inchar` directly to block for events or user input without
|
||||
// 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
|
||||
// directly.
|
||||
// mapping engine.
|
||||
(void)os_inchar(NULL, 0, -1, 0);
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user