/** * A vdo_wait_queue is a circular singly linked list of entries waiting to be notified * of a change in a condition. Keeping a circular list allows the vdo_wait_queue * structure to simply be a pointer to the tail (newest) entry, supporting * constant-time enqueue and dequeue operations. A null pointer is an empty waitq. * * An empty waitq: * waitq0.last_waiter -> NULL * * A singleton waitq: * waitq1.last_waiter -> entry1 -> entry1 -> [...] * * A three-element waitq: * waitq2.last_waiter -> entry3 -> entry1 -> entry2 -> entry3 -> [...] * * linux/wait.h's wait_queue_head is _not_ used because vdo_wait_queue's * interface is much less complex (doesn't need locking, priorities or timers). * Made possible by vdo's thread-based resource allocation and locking; and * the polling nature of vdo_wait_queue consumers. * * FIXME: could be made to use a linux/list.h's list_head but its extra barriers * really aren't needed. Nor is a doubly linked list, but vdo_wait_queue could * make use of __list_del_clearprev() -- but that would compromise the ability * to make full use of linux's list interface.
*/
struct vdo_waiter;
struct vdo_wait_queue { /* The tail of the queue, the last (most recently added) entry */ struct vdo_waiter *last_waiter; /* The number of waiters currently in the queue */
size_t length;
};
/** * vdo_waiter_callback_fn - Callback type that will be called to resume processing * of a waiter after it has been removed from its wait queue.
*/ typedefvoid (*vdo_waiter_callback_fn)(struct vdo_waiter *waiter, void *context);
/** * vdo_waiter_match_fn - Method type for waiter matching methods. * * Returns false if the waiter does not match.
*/ typedefbool (*vdo_waiter_match_fn)(struct vdo_waiter *waiter, void *context);
/* The structure for entries in a vdo_wait_queue. */ struct vdo_waiter { /* * The next waiter in the waitq. If this entry is the last waiter, then this * is actually a pointer back to the head of the waitq.
*/ struct vdo_waiter *next_waiter;
/* Optional waiter-specific callback to invoke when dequeuing this waiter. */
vdo_waiter_callback_fn callback;
};
/** * vdo_waiter_is_waiting() - Check whether a waiter is waiting. * @waiter: The waiter to check. * * Return: true if the waiter is on some vdo_wait_queue.
*/ staticinlinebool vdo_waiter_is_waiting(struct vdo_waiter *waiter)
{ return (waiter->next_waiter != NULL);
}
/** * vdo_waitq_has_waiters() - Check whether a vdo_wait_queue has any entries waiting. * @waitq: The vdo_wait_queue to query. * * Return: true if there are any waiters in the waitq.
*/ staticinlinebool __must_check vdo_waitq_has_waiters(conststruct vdo_wait_queue *waitq)
{ return (waitq->last_waiter != NULL);
}
/** * vdo_waitq_num_waiters() - Return the number of waiters in a vdo_wait_queue. * @waitq: The vdo_wait_queue to query. * * Return: The number of waiters in the waitq.
*/ staticinline size_t __must_check vdo_waitq_num_waiters(conststruct vdo_wait_queue *waitq)
{ return waitq->length;
}
#endif/* VDO_WAIT_QUEUE_H */
Messung V0.5
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.