#include <isc/assertions.h>
#include <isc/boolean.h>
#include <isc/mutex.h>
Go to the source code of this file.
Defines | |
#define | ISC_QUEUE_H 1 |
#define | ISC_QLINK_INSIST(x) (void)0 |
#define | ISC_QLINK(type) struct { type *prev, *next; } |
#define | ISC_QLINK_INIT(elt, link) |
#define | ISC_QLINK_LINKED(elt, link) ((void*)(elt)->link.next != (void*)(-1)) |
#define | ISC_QUEUE(type) |
#define | ISC_QUEUE_INIT(queue, link) |
#define | ISC_QUEUE_EMPTY(queue) ISC_TF((queue).head == NULL) |
#define | ISC_QUEUE_DESTROY(queue) |
#define | ISC_QUEUE_PUSH(queue, elt, link) |
#define | ISC_QUEUE_POP(queue, link, ret) |
#define | ISC_QUEUE_UNLINK(queue, elt, link) |
#define ISC_QLINK_INIT | ( | elt, | |||
link | ) |
Definition at line 47 of file queue.h.
Referenced by ATF_TC_BODY(), client_shutdown(), and exit_check().
#define ISC_QUEUE | ( | type | ) |
Value:
struct { \ type *head, *tail; \ isc_mutex_t headlock, taillock; \ }
#define ISC_QUEUE_INIT | ( | queue, | |||
link | ) |
Value:
do { \ (void) isc_mutex_init(&(queue).taillock); \ (void) isc_mutex_init(&(queue).headlock); \ (queue).tail = (queue).head = NULL; \ } while (0)
Definition at line 54 of file queue.h.
Referenced by ATF_TC_BODY(), and ns_clientmgr_create().
#define ISC_QUEUE_EMPTY | ( | queue | ) | ISC_TF((queue).head == NULL) |
#define ISC_QUEUE_DESTROY | ( | queue | ) |
Value:
do { \ ISC_QLINK_INSIST(ISC_QUEUE_EMPTY(queue)); \ (void) isc_mutex_destroy(&(queue).taillock); \ (void) isc_mutex_destroy(&(queue).headlock); \ } while (0)
Definition at line 63 of file queue.h.
Referenced by ATF_TC_BODY(), and clientmgr_destroy().
#define ISC_QUEUE_PUSH | ( | queue, | |||
elt, | |||||
link | ) |
Value:
do { \ isc_boolean_t headlocked = ISC_FALSE; \ ISC_QLINK_INSIST(!ISC_QLINK_LINKED(elt, link)); \ if ((queue).head == NULL) { \ LOCK(&(queue).headlock); \ headlocked = ISC_TRUE; \ } \ LOCK(&(queue).taillock); \ if ((queue).tail == NULL && !headlocked) { \ UNLOCK(&(queue).taillock); \ LOCK(&(queue).headlock); \ LOCK(&(queue).taillock); \ headlocked = ISC_TRUE; \ } \ (elt)->link.prev = (queue).tail; \ (elt)->link.next = NULL; \ if ((queue).tail != NULL) \ (queue).tail->link.next = (elt); \ (queue).tail = (elt); \ UNLOCK(&(queue).taillock); \ if (headlocked) { \ if ((queue).head == NULL) \ (queue).head = (elt); \ UNLOCK(&(queue).headlock); \ } \ } while (0)
Definition at line 96 of file queue.h.
Referenced by ATF_TC_BODY(), and exit_check().
#define ISC_QUEUE_POP | ( | queue, | |||
link, | |||||
ret | ) |
Value:
do { \ LOCK(&(queue).headlock); \ ret = (queue).head; \ while (ret != NULL) { \ if (ret->link.next == NULL) { \ LOCK(&(queue).taillock); \ if (ret->link.next == NULL) { \ (queue).head = (queue).tail = NULL; \ UNLOCK(&(queue).taillock); \ break; \ }\ UNLOCK(&(queue).taillock); \ } \ (queue).head = ret->link.next; \ (queue).head->link.prev = NULL; \ break; \ } \ UNLOCK(&(queue).headlock); \ if (ret != NULL) \ (ret)->link.next = (ret)->link.prev = (void *)(-1); \ } while(0)
Definition at line 124 of file queue.h.
Referenced by ATF_TC_BODY(), get_client(), and get_worker().
#define ISC_QUEUE_UNLINK | ( | queue, | |||
elt, | |||||
link | ) |
Value:
do { \ ISC_QLINK_INSIST(ISC_QLINK_LINKED(elt, link)); \ LOCK(&(queue).headlock); \ LOCK(&(queue).taillock); \ if ((elt)->link.prev == NULL) \ (queue).head = (elt)->link.next; \ else \ (elt)->link.prev->link.next = (elt)->link.next; \ if ((elt)->link.next == NULL) \ (queue).tail = (elt)->link.prev; \ else \ (elt)->link.next->link.prev = (elt)->link.prev; \ UNLOCK(&(queue).taillock); \ UNLOCK(&(queue).headlock); \ (elt)->link.next = (elt)->link.prev = (void *)(-1); \ } while(0)
Definition at line 147 of file queue.h.
Referenced by ATF_TC_BODY(), and client_shutdown().