unqueue_matching: Add max_depth argument

Look only at the last `max_depth` items on the queue, at most.
This commit is contained in:
Michael Cook
2020-10-24 09:50:00 -04:00
committed by Michael Cook
parent 67e190960f
commit ade37fea82
4 changed files with 53 additions and 15 deletions
+3 -2
View File
@@ -55,7 +55,8 @@ void *unqueue(queue_t *q);
typedef bool queue_matcher_t(void *wanted, void *candidate);
/* Unqueue the most recently queued item for watch `matcher(wanted, candidate)`
/* Unqueue the most recently queued item for which `matcher(wanted, candidate)`
returns true where `candidate` is an item currently on the queue.
Look only at the last `max_depth` items on the queue, at most.
Returns the candidate item, or NULL if none matches */
void *unqueue_matching(queue_t *q, queue_matcher_t *matcher, void *wanted);
void *unqueue_matching(queue_t *q, size_t max_depth, queue_matcher_t *matcher, void *wanted);