diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-04-27 14:38:41 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-04-28 19:20:09 +0200 |
commit | 8f59d1483934f91011b755406251136c406e77f6 (patch) | |
tree | 864bf25c65c6cfcd4e17c0ebd04afdad1342c268 /src | |
parent | f17a8185191b778960953508a5bf9b5f95b0560c (diff) | |
download | rneovim-8f59d1483934f91011b755406251136c406e77f6.tar.gz rneovim-8f59d1483934f91011b755406251136c406e77f6.tar.bz2 rneovim-8f59d1483934f91011b755406251136c406e77f6.zip |
event: Remove "priority" concept.
It was replaced by the "child queue" concept (MultiQueue).
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/event/defs.h | 13 | ||||
-rw-r--r-- | src/nvim/event/multiqueue.c | 27 | ||||
-rw-r--r-- | src/nvim/event/multiqueue.h | 2 | ||||
-rw-r--r-- | src/nvim/message.c | 2 | ||||
-rw-r--r-- | src/nvim/tui/input.c | 4 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 2 | ||||
-rw-r--r-- | src/nvim/ui.c | 2 | ||||
-rw-r--r-- | src/nvim/ui_bridge.c | 4 |
8 files changed, 11 insertions, 45 deletions
diff --git a/src/nvim/event/defs.h b/src/nvim/event/defs.h index 509a3f8e7f..cc875d74b9 100644 --- a/src/nvim/event/defs.h +++ b/src/nvim/event/defs.h @@ -6,23 +6,16 @@ #define EVENT_HANDLER_MAX_ARGC 6 -typedef enum { - kEvPriorityNormal = 1, - kEvPriorityAsync = 2, // safe to run in any state -} EventPriority; - typedef void (*argv_callback)(void **argv); typedef struct message { - int priority; argv_callback handler; void *argv[EVENT_HANDLER_MAX_ARGC]; } Event; typedef void(*event_scheduler)(Event event, void *data); -#define VA_EVENT_INIT(event, p, h, a) \ +#define VA_EVENT_INIT(event, h, a) \ do { \ assert(a <= EVENT_HANDLER_MAX_ARGC); \ - (event)->priority = p; \ (event)->handler = h; \ if (a) { \ va_list args; \ @@ -34,11 +27,11 @@ typedef void(*event_scheduler)(Event event, void *data); } \ } while (0) -static inline Event event_create(int priority, argv_callback cb, int argc, ...) +static inline Event event_create(argv_callback cb, int argc, ...) { assert(argc <= EVENT_HANDLER_MAX_ARGC); Event event; - VA_EVENT_INIT(&event, priority, cb, argc); + VA_EVENT_INIT(&event, cb, argc); return event; } diff --git a/src/nvim/event/multiqueue.c b/src/nvim/event/multiqueue.c index 66a261b554..ef9f3f1870 100644 --- a/src/nvim/event/multiqueue.c +++ b/src/nvim/event/multiqueue.c @@ -152,33 +152,6 @@ void multiqueue_process_events(MultiQueue *this) } } -void multiqueue_process_priority(MultiQueue *this, int priority) -{ - assert(this); - QUEUE *start = QUEUE_HEAD(&this->headtail); - QUEUE *cur = start; - while (!multiqueue_empty(this)) { - MultiQueueItem *item = multiqueue_node_data(cur); - assert(!item->link || !this->parent); // Only a parent queue has link-nodes - Event ev = multiqueueitem_get_event(item, false); - - if (ev.priority >= priority) { - if (ev.handler) { - ev.handler(ev.argv); - } - // Processed. Remove this item and get the new head. - (void)multiqueue_remove(this); - cur = QUEUE_HEAD(&this->headtail); - } else { - // Not processed. Skip this item and get the next one. - cur = cur->next->next; - if (!cur || cur == start) { - break; - } - } - } -} - /// Removes all events without processing them. void multiqueue_purge_events(MultiQueue *this) { diff --git a/src/nvim/event/multiqueue.h b/src/nvim/event/multiqueue.h index 72145482aa..a688107665 100644 --- a/src/nvim/event/multiqueue.h +++ b/src/nvim/event/multiqueue.h @@ -10,7 +10,7 @@ typedef struct multiqueue MultiQueue; typedef void (*put_callback)(MultiQueue *multiq, void *data); #define multiqueue_put(q, h, ...) \ - multiqueue_put_event(q, event_create(kEvPriorityNormal, h, __VA_ARGS__)); + multiqueue_put_event(q, event_create(h, __VA_ARGS__)); #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/message.c b/src/nvim/message.c index 146937c25a..696855e3aa 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -604,7 +604,7 @@ void msg_schedule_emsgf(const char *const fmt, ...) va_end(ap); char *s = xstrdup((char *)IObuff); - loop_schedule(&main_loop, event_create(1, msg_emsgf_event, 1, s)); + loop_schedule(&main_loop, event_create(msg_emsgf_event, 1, s)); } /* diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index b86ab8cf2f..3d37fabeee 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -102,7 +102,7 @@ static void flush_input(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(1, wait_input_enqueue, 1, input)); + loop_schedule(&main_loop, event_create(wait_input_enqueue, 1, input)); input->waiting = true; while (input->waiting) { uv_cond_wait(&input->key_buffer_cond, &input->key_buffer_mutex); @@ -352,7 +352,7 @@ static void read_cb(Stream *stream, RBuffer *buf, size_t c, void *data, stream_close(&input->read_stream, NULL, NULL); multiqueue_put(input->loop->fast_events, restart_reading, 1, input); } else { - loop_schedule(&main_loop, event_create(1, input_done_event, 0)); + loop_schedule(&main_loop, event_create(input_done_event, 0)); } return; } diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 356221f7ce..5653924154 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -773,7 +773,7 @@ static void tui_suspend(UI *ui) // before continuing. This is done in another callback to avoid // loop_poll_events recursion multiqueue_put_event(data->loop->fast_events, - event_create(1, suspend_event, 1, ui)); + event_create(suspend_event, 1, ui)); } static void tui_set_title(UI *ui, char *title) diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 713dffb46c..924a4192bc 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -198,7 +198,7 @@ static void ui_refresh_event(void **argv) void ui_schedule_refresh(void) { - loop_schedule(&main_loop, event_create(1, ui_refresh_event, 0)); + loop_schedule(&main_loop, event_create(ui_refresh_event, 0)); } void ui_resize(int new_width, int new_height) diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c index b7b12ae39e..d790770892 100644 --- a/src/nvim/ui_bridge.c +++ b/src/nvim/ui_bridge.c @@ -40,13 +40,13 @@ static argv_callback uilog_event = NULL; uilog_event = ui_bridge_##name##_event; \ } \ ((UIBridgeData *)ui)->scheduler( \ - event_create(1, ui_bridge_##name##_event, argc, __VA_ARGS__), UI(ui)); \ + event_create(ui_bridge_##name##_event, argc, __VA_ARGS__), UI(ui)); \ } while (0) #else // Schedule a function call on the UI bridge thread. #define UI_CALL(ui, name, argc, ...) \ ((UIBridgeData *)ui)->scheduler( \ - event_create(1, ui_bridge_##name##_event, argc, __VA_ARGS__), UI(ui)) + event_create(ui_bridge_##name##_event, argc, __VA_ARGS__), UI(ui)) #endif #define INT2PTR(i) ((void *)(uintptr_t)i) |