picq.h File Reference
#include <yaf/autoinc.h>

Go to the source code of this file.

Functions

void piqPick (void *vq, void *vn)
 Pick a node from a given pickable queue.
 
void piqEnQ (void *vq, void *vn)
 Enqueue a node at the head of a given pickable queue.
 
void piqUnshift (void *vq, void *vn)
 Enqueue a node at the tail of a given pickable queue.
 
void * piqShift (void *vq)
 Dequeue a node from the head of a given pickable queue.
 
void * piqDeQ (void *vq)
 Dequeue a node from the tail of a given pickable queue.
 

Detailed Description

Generic Pickable Queue.

A pickable queue's elements may be removed from any point in the queue, and added to the queue's head or tail. Together with a hash table to locate mid-queue elements, this can be used to implement idle timeout of its elements.

Where present, a vq argument is a void pointer to a queue. A queue's first two members must be a pointer to the tail (last node) of the queue and a pointer to the head (first node) of the queue.

Where present, a vn argument is a void pointer to a queue node. A queue node's first two elements must be a pointer to the previous node in the queue and a pointer to the next node in the queue.

Function Documentation

◆ piqDeQ()

void * piqDeQ ( void *  vq)

Dequeue a node from the tail of a given pickable queue.

Analogous to finding the tail, picking it, then returning it. The node is removed from the queue, and its previous and next pointers are set to NULL. Returns NULL if the queue is empty.

Parameters
vqqueue to remove from
Returns
the dequeued tail of the queue, or NULL if empty.

◆ piqEnQ()

void piqEnQ ( void *  vq,
void *  vn 
)

Enqueue a node at the head of a given pickable queue.

The node must not be an element in another queue; that is, its own previous and next pointers must be NULL. To move a node from one queue to another, use piqPick() first.

Parameters
vqqueue to enqueue to
vnnode to enqueue

◆ piqPick()

void piqPick ( void *  vq,
void *  vn 
)

Pick a node from a given pickable queue.

The node is removed from the queue, and its previous and next pointers are set to NULL. It is assumed that the node is actually an element of the given queue; undefined behavior may result if this is not the case.

Parameters
vqqueue to remove from
vnnode to remove

◆ piqShift()

void * piqShift ( void *  vq)

Dequeue a node from the head of a given pickable queue.

Analogous to finding the head, picking it, then returning it. The node is removed from the queue, and its previous and next pointers are set to NULL. Returns NULL if the queue is empty.

Parameters
vqqueue to remove from
Returns
the dequeued head of the queue, or NULL if empty.

◆ piqUnshift()

void piqUnshift ( void *  vq,
void *  vn 
)

Enqueue a node at the tail of a given pickable queue.

The node must not be an element in another queue; that is, its own previous and next pointers must be NULL. To move a node from one queue to another, use piqPick() first.

Parameters
vqqueue to enqueue to
vnnode to enqueue