Concord - C Discord API library
A Discord API wrapper library written in C
queue.h File Reference
#include <stddef.h>
Include dependency graph for queue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define QUEUE(type)   QUEUE
 
#define QUEUE_NEXT(q)   (*(QUEUE **) &((*(q))[0]))
 
#define QUEUE_PREV(q)   (*(QUEUE **) &((*(q))[1]))
 
#define QUEUE_PREV_NEXT(q)   (QUEUE_NEXT(QUEUE_PREV(q)))
 
#define QUEUE_NEXT_PREV(q)   (QUEUE_PREV(QUEUE_NEXT(q)))
 
#define QUEUE_DATA(ptr, type, field)    ((type *) ((char *) (ptr) - offsetof(type, field)))
 
#define QUEUE_FOREACH(q, h)    for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q))
 
#define QUEUE_EMPTY(q)    ((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q))
 
#define QUEUE_HEAD(q)    (QUEUE_NEXT(q))
 
#define QUEUE_INIT(q)
 
#define QUEUE_ADD(h, n)
 
#define QUEUE_SPLIT(h, q, n)
 
#define QUEUE_MOVE(h, n)
 
#define QUEUE_INSERT_HEAD(h, q)
 
#define QUEUE_INSERT_TAIL(h, q)
 
#define QUEUE_REMOVE(q)
 

Typedefs

typedef void * QUEUE[2]
 

Macro Definition Documentation

◆ QUEUE

#define QUEUE (   type)    QUEUE

◆ QUEUE_NEXT

#define QUEUE_NEXT (   q)    (*(QUEUE **) &((*(q))[0]))

◆ QUEUE_PREV

#define QUEUE_PREV (   q)    (*(QUEUE **) &((*(q))[1]))

◆ QUEUE_PREV_NEXT

#define QUEUE_PREV_NEXT (   q)    (QUEUE_NEXT(QUEUE_PREV(q)))

◆ QUEUE_NEXT_PREV

#define QUEUE_NEXT_PREV (   q)    (QUEUE_PREV(QUEUE_NEXT(q)))

◆ QUEUE_DATA

#define QUEUE_DATA (   ptr,
  type,
  field 
)     ((type *) ((char *) (ptr) - offsetof(type, field)))

◆ QUEUE_FOREACH

#define QUEUE_FOREACH (   q,
 
)     for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q))

◆ QUEUE_EMPTY

#define QUEUE_EMPTY (   q)     ((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q))

◆ QUEUE_HEAD

#define QUEUE_HEAD (   q)     (QUEUE_NEXT(q))

◆ QUEUE_INIT

#define QUEUE_INIT (   q)
Value:
do { \
QUEUE_NEXT(q) = (q); \
QUEUE_PREV(q) = (q); \
} \
while (0)

◆ QUEUE_ADD

#define QUEUE_ADD (   h,
 
)
Value:
do { \
QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \
QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \
QUEUE_PREV(h) = QUEUE_PREV(n); \
QUEUE_PREV_NEXT(h) = (h); \
} \
while (0)
#define QUEUE_PREV(q)
Definition: queue.h:28
#define QUEUE_NEXT(q)
Definition: queue.h:27

◆ QUEUE_SPLIT

#define QUEUE_SPLIT (   h,
  q,
 
)
Value:
do { \
QUEUE_PREV(n) = QUEUE_PREV(h); \
QUEUE_PREV_NEXT(n) = (n); \
QUEUE_NEXT(n) = (q); \
QUEUE_PREV(h) = QUEUE_PREV(q); \
QUEUE_PREV_NEXT(h) = (h); \
QUEUE_PREV(q) = (n); \
} \
while (0)

◆ QUEUE_MOVE

#define QUEUE_MOVE (   h,
 
)
Value:
do { \
if (QUEUE_EMPTY(h)) \
QUEUE_INIT(n); \
else { \
QUEUE* q = QUEUE_HEAD(h); \
QUEUE_SPLIT(h, q, n); \
} \
} \
while (0)
#define QUEUE_EMPTY(q)
Definition: queue.h:42
#define QUEUE_HEAD(q)
Definition: queue.h:45

◆ QUEUE_INSERT_HEAD

#define QUEUE_INSERT_HEAD (   h,
 
)
Value:
do { \
QUEUE_NEXT(q) = QUEUE_NEXT(h); \
QUEUE_PREV(q) = (h); \
QUEUE_NEXT_PREV(q) = (q); \
QUEUE_NEXT(h) = (q); \
} \
while (0)

◆ QUEUE_INSERT_TAIL

#define QUEUE_INSERT_TAIL (   h,
 
)
Value:
do { \
QUEUE_NEXT(q) = (h); \
QUEUE_PREV(q) = QUEUE_PREV(h); \
QUEUE_PREV_NEXT(q) = (q); \
QUEUE_PREV(h) = (q); \
} \
while (0)

◆ QUEUE_REMOVE

#define QUEUE_REMOVE (   q)
Value:
do { \
QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \
QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \
} \
while (0)

Typedef Documentation

◆ 

{ ... } ::QUEUE

buckets that are currently pending (have pending requests)

next requests queue

requests for recycling

pending requests waiting to be assigned to a bucket

finished requests that are done performing and waiting for their callbacks to be called from the main thread