aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval/funcs.c2
-rw-r--r--src/nvim/event/loop.c4
-rw-r--r--src/nvim/event/multiqueue.c18
-rw-r--r--src/nvim/terminal.c2
-rw-r--r--src/nvim/tui/tui.c2
5 files changed, 15 insertions, 13 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 7cec2aaa06..c8ad61f885 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -4191,7 +4191,7 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
list_T *args = argvars[0].vval.v_list;
Channel **jobs = xcalloc((size_t)tv_list_len(args), sizeof(*jobs));
- MultiQueue *waiting_jobs = multiqueue_new_parent(loop_on_put, &main_loop);
+ MultiQueue *waiting_jobs = multiqueue_new(loop_on_put, &main_loop);
// Validate, prepare jobs for waiting.
int i = 0;
diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c
index f8b149ec78..050419b8e9 100644
--- a/src/nvim/event/loop.c
+++ b/src/nvim/event/loop.c
@@ -21,9 +21,9 @@ void loop_init(Loop *loop, void *data)
loop->closing = false;
loop->uv.data = loop;
kv_init(loop->children);
- loop->events = multiqueue_new_parent(loop_on_put, loop);
+ loop->events = multiqueue_new(loop_on_put, loop);
loop->fast_events = multiqueue_new_child(loop->events);
- loop->thread_events = multiqueue_new_parent(NULL, NULL);
+ loop->thread_events = multiqueue_new(NULL, NULL);
uv_mutex_init(&loop->mutex);
uv_async_init(&loop->uv, &loop->async, async_cb);
uv_signal_init(&loop->uv, &loop->children_watcher);
diff --git a/src/nvim/event/multiqueue.c b/src/nvim/event/multiqueue.c
index 5072bd774d..859051e594 100644
--- a/src/nvim/event/multiqueue.c
+++ b/src/nvim/event/multiqueue.c
@@ -67,7 +67,7 @@ struct multiqueue_item {
struct multiqueue {
MultiQueue *parent;
QUEUE headtail; // circularly-linked
- PutCallback put_cb;
+ PutCallback on_put; // Called on the parent (if any) when an item is enqueued in a child.
void *data;
size_t size;
};
@@ -84,26 +84,28 @@ typedef struct {
static Event NILEVENT = { .handler = NULL, .argv = { NULL } };
-MultiQueue *multiqueue_new_parent(PutCallback put_cb, void *data)
+/// Creates a new root (parentless) queue, which may gain child queues via `multiqueue_new_child`.
+MultiQueue *multiqueue_new(PutCallback on_put, void *data)
{
- return multiqueue_new(NULL, put_cb, data);
+ return _multiqueue_new(NULL, on_put, data);
}
+/// Creates a new queue as a child of a `parent` queue.
MultiQueue *multiqueue_new_child(MultiQueue *parent)
FUNC_ATTR_NONNULL_ALL
{
assert(!parent->parent); // parent cannot have a parent, more like a "root"
parent->size++;
- return multiqueue_new(parent, NULL, NULL);
+ return _multiqueue_new(parent, NULL, NULL);
}
-static MultiQueue *multiqueue_new(MultiQueue *parent, PutCallback put_cb, void *data)
+static MultiQueue *_multiqueue_new(MultiQueue *parent, PutCallback on_put, void *data)
{
MultiQueue *rv = xmalloc(sizeof(MultiQueue));
QUEUE_INIT(&rv->headtail);
rv->size = 0;
rv->parent = parent;
- rv->put_cb = put_cb;
+ rv->on_put = on_put;
rv->data = data;
return rv;
}
@@ -135,8 +137,8 @@ void multiqueue_put_event(MultiQueue *self, Event event)
{
assert(self);
multiqueue_push(self, event);
- if (self->parent && self->parent->put_cb) {
- self->parent->put_cb(self->parent, self->parent->data);
+ if (self->parent && self->parent->on_put) {
+ self->parent->on_put(self->parent, self->parent->data);
}
}
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 2ca71e6dde..f4acfb486c 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -498,7 +498,7 @@ void terminal_open(Terminal **termpp, buf_T *buf, TerminalOptions opts)
// can create an infinite loop (#32753).
// This queue is never processed directly: when the terminal is refreshed, all
// events from this queue are copied back onto the main event queue.
- term->pending.events = multiqueue_new_parent(NULL, NULL);
+ term->pending.events = multiqueue_new(NULL, NULL);
aco_save_T aco;
aucmd_prepbuf(&aco, buf);
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 31f95a1006..7c93be844a 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -1,4 +1,4 @@
-// Terminal UI functions. Invoked (by ui_client.c) on the UI process.
+// Terminal UI functions. Invoked by the UI process (ui_client.c), not the server.
#include <assert.h>
#include <inttypes.h>