aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lib/queue.h
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-10-03 10:46:11 +0200
committerJustin M. Keyes <justinkz@gmail.com>2016-12-09 18:51:17 +0100
commit043f85210a06168e36f103950897e00918504f6f (patch)
tree0559ca04b5a34bb6af6934bca9d3efedeb6ef734 /src/nvim/lib/queue.h
parent5082af415f762e5f5974214e32deff883141bfc2 (diff)
downloadrneovim-043f85210a06168e36f103950897e00918504f6f.tar.gz
rneovim-043f85210a06168e36f103950897e00918504f6f.tar.bz2
rneovim-043f85210a06168e36f103950897e00918504f6f.zip
tui: "backpressure": Drop messages to avoid flooding.
Closes #1234 multiqueue: - Implement multiqueue_size() - Rename MultiQueueItem.parent to MultiQueueItem.parent_item, to avoid confusion with MultiQueue.parent.
Diffstat (limited to 'src/nvim/lib/queue.h')
-rw-r--r--src/nvim/lib/queue.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/nvim/lib/queue.h b/src/nvim/lib/queue.h
index 9fcedf298f..ab9270081e 100644
--- a/src/nvim/lib/queue.h
+++ b/src/nvim/lib/queue.h
@@ -1,3 +1,8 @@
+// Queue implemented by circularly-linked list.
+//
+// Adapted from libuv. Simpler and more efficient than klist.h for implementing
+// queues that support arbitrary insertion/removal.
+//
// Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
//
// Permission to use, copy, modify, and/or distribute this software for any
@@ -28,6 +33,8 @@ typedef struct _queue {
#define QUEUE_DATA(ptr, type, field) \
((type *)((char *)(ptr) - offsetof(type, field)))
+// Important note: mutating the list while QUEUE_FOREACH is
+// iterating over its elements results in undefined behavior.
#define QUEUE_FOREACH(q, h) \
for ( /* NOLINT(readability/braces) */ \
(q) = (h)->next; (q) != (h); (q) = (q)->next)
@@ -56,17 +63,6 @@ static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n)
h->prev->next = h;
}
-static inline void QUEUE_SPLIT(QUEUE *const h, QUEUE *const q, QUEUE *const n)
- FUNC_ATTR_ALWAYS_INLINE
-{
- n->prev = h->prev;
- n->prev->next = n;
- n->next = q;
- h->prev = q->prev;
- h->prev->next = h;
- q->prev = n;
-}
-
static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q)
FUNC_ATTR_ALWAYS_INLINE
{