From 043f85210a06168e36f103950897e00918504f6f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 3 Oct 2016 10:46:11 +0200 Subject: 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. --- src/nvim/lib/queue.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/nvim/lib/queue.h') 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 // // 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 { -- cgit