netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
queue.h File Reference

Go to the source code of this file.

## Data Structures
struct | qnode

## Macros
#define | queue_free(q)

## Typedefs
typedef struct qnode | qnode_t
typedef qnode_t | q_t

## Functions
q_t * | queue_init (void)
void | queue_destroy (q_t *q, void(*callback)(void *))
qnode_t * | enqueue (q_t *q, void *data)
qnode_t * | prequeue (q_t *q, void *data)
qnode_t * | queue_move_to_tail (q_t *q, qnode_t *nodenode)
| Move existing node to tail (MRU) without reallocation.
qnode_t * | queue_move_to_tail_of (q_t *from_q, q_t *to_q, qnode_t *nodenode)
| Move node from one queue to another without memory reallocation.
void * | dequeue (q_t *q)

## Macro Definition Documentation

## ◆ queue_free

#define queue_free | ( |  | q | ) |

Value:
queue_destroy((q), free)
queue_destroy
void queue_destroy(q_t *q, void(*callback)(void *))
Definition queue.c:181

## Typedef Documentation

## ◆ q_t

typedef qnode_t q_t

## ◆ qnode_t

typedef struct qnode qnode_t

## Function Documentation

## ◆ dequeue()

void * dequeue | ( | q_t * | q | ) |
| extern

Take from head

## ◆ enqueue()

qnode_t * enqueue | ( | q_t * | q,
|  | void * | data )
| extern

Insert at tail

## ◆ prequeue()

qnode_t * prequeue | ( | q_t * | q,
|  | void * | data )
| extern

Insert at head

## ◆ queue_destroy()

void queue_destroy | ( | q_t * | q,
|  | void(* | callback )(void *) )
| extern

## ◆ queue_init()

q_t * queue_init | ( | void |  | ) |
| extern

## ◆ queue_move_to_tail()

qnode_t * queue_move_to_tail | ( | q_t * | q,
|  | qnode_t * | node )
| extern

Move existing node to tail (MRU) without reallocation.

This function provides O(1) move-to-tail operation without malloc/free overhead. Used by ARC cache to efficiently update T2 on cache hits.

Parameters

  [in] | q | Queue (circular doubly-linked list with sentinel)
  [in] | node | Node to move to tail (must currently be in queue q)

Returns
  The same node pointer (now at tail/MRU), or NULL on error

Note
  The node pointer remains valid and unchanged - only its position changes
  If node is already at tail, this is a no-op (fast path)
  This is thread-safe if external locking is used (same as other queue ops)

## ◆ queue_move_to_tail_of()

qnode_t * queue_move_to_tail_of | ( | q_t * | from_q,
|  | q_t * | to_q,
|  | qnode_t * | node )
| extern

Move node from one queue to another without memory reallocation.

Removes node from source queue and adds it to tail of destination queue. The node pointer remains valid and unchanged - enables zero-allocation transitions between ARC lists (T1→T2, T1→B1, T2→B2, B1→T2, B2→T2).

Parameters

  [in] | from_q | Source queue (node must be in this queue)
  [in] | to_q | Destination queue
  [in] | node | Node to move

Returns
  The same node pointer (now in dest queue), or NULL on error