events: loop_schedule() is unclear, rename it loop_schedule_fast()

This commit is contained in:
Björn Linse
2019-08-29 12:48:01 +02:00
parent 7a85792884
commit f8b5d6e124
5 changed files with 15 additions and 11 deletions

View File

@@ -71,7 +71,7 @@ bool loop_poll_events(Loop *loop, int ms)
return timeout_expired;
}
/// Schedules an event from another thread.
/// Schedules a fast 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
@@ -79,7 +79,7 @@ bool loop_poll_events(Loop *loop, int ms)
/// (VimState.execute), so redraw and other side-effects are likely to be
/// skipped.
/// @see loop_schedule_deferred
void loop_schedule(Loop *loop, Event event)
void loop_schedule_fast(Loop *loop, Event event)
{
uv_mutex_lock(&loop->mutex);
multiqueue_put_event(loop->thread_events, event);
@@ -87,15 +87,15 @@ void loop_schedule(Loop *loop, Event event)
uv_mutex_unlock(&loop->mutex);
}
/// Schedules an event from another thread. Unlike loop_schedule(), the event
/// is forwarded to `Loop.events`, instead of being processed immediately.
/// Schedules an event from another thread. Unlike loop_schedule_fast(), the
/// event is forwarded to `Loop.events`, instead of being processed immediately.
///
/// @see loop_schedule
/// @see loop_schedule_fast
void loop_schedule_deferred(Loop *loop, Event event)
{
Event *eventp = xmalloc(sizeof(*eventp));
*eventp = event;
loop_schedule(loop, event_create(loop_deferred_event, 2, loop, eventp));
loop_schedule_fast(loop, event_create(loop_deferred_event, 2, loop, eventp));
}
static void loop_deferred_event(void **argv)
{

View File

@@ -753,7 +753,7 @@ void msg_schedule_emsgf(const char *const fmt, ...)
va_end(ap);
char *s = xstrdup((char *)IObuff);
loop_schedule(&main_loop, event_create(msg_emsgf_event, 1, s));
multiqueue_put(main_loop.events, msg_emsgf_event, 1, s);
}
/*

View File

@@ -164,7 +164,7 @@ static void tinput_flush(TermInput *input, bool wait_until_empty)
size_t drain_boundary = wait_until_empty ? 0 : 0xff;
do {
uv_mutex_lock(&input->key_buffer_mutex);
loop_schedule(&main_loop, event_create(tinput_wait_enqueue, 1, input));
loop_schedule_fast(&main_loop, event_create(tinput_wait_enqueue, 1, input));
input->waiting = true;
while (input->waiting) {
uv_cond_wait(&input->key_buffer_cond, &input->key_buffer_mutex);
@@ -522,7 +522,7 @@ static void tinput_read_cb(Stream *stream, RBuffer *buf, size_t count_,
TermInput *input = data;
if (eof) {
loop_schedule(&main_loop, event_create(tinput_done_event, 0));
loop_schedule_fast(&main_loop, event_create(tinput_done_event, 0));
return;
}

View File

@@ -454,7 +454,7 @@ static void tui_scheduler(Event event, void *d)
{
UI *ui = d;
TUIData *data = ui->data;
loop_schedule(data->loop, event); // `tui_loop` local to tui_main().
loop_schedule_fast(data->loop, event); // `tui_loop` local to tui_main().
}
#ifdef UNIX

View File

@@ -228,7 +228,11 @@ static void ui_refresh_event(void **argv)
void ui_schedule_refresh(void)
{
loop_schedule(&main_loop, event_create(ui_refresh_event, 0));
// TODO(bfredl): "fast" is not optimal. UI should be refreshed only at
// deferred processing plus a few more blocked-on-input situtions like
// wait_return(), but not any os_breakcheck(). Alternatively make this
// defered and make wait_return() process deferred events already.
loop_schedule_fast(&main_loop, event_create(ui_refresh_event, 0));
}
void ui_default_colors_set(void)