netatalk  4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
queue.c File Reference
#include <stdlib.h>
#include <atalk/queue.h>

Functions

static qnode_talloc_init_node (void *data)
 
q_tqueue_init (void)
 
qnode_tenqueue (q_t *q, void *data)
 
qnode_tqueue_move_to_tail_of (q_t *from_q, q_t *to_q, qnode_t *node)
 Move node from one queue to another without memory reallocation.
 
qnode_tqueue_move_to_tail (q_t *q, qnode_t *node)
 Move existing node to tail (MRU) without reallocation.
 
qnode_tprequeue (q_t *q, void *data)
 
void * dequeue (q_t *q)
 
void queue_destroy (q_t *q, void(*callback)(void *))
 

Detailed Description

Netatalk utility functions: queue

Function Documentation

◆ alloc_init_node()

static qnode_t * alloc_init_node ( void *  data)
static

◆ dequeue()

void * dequeue ( q_t q)

Take from head

◆ enqueue()

qnode_t * enqueue ( q_t q,
void *  data 
)

Insert at tail

◆ prequeue()

qnode_t * prequeue ( q_t q,
void *  data 
)

Insert at head

◆ queue_destroy()

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

◆ queue_init()

q_t * queue_init ( void  )

◆ queue_move_to_tail()

qnode_t * queue_move_to_tail ( q_t q,
qnode_t node 
)

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]qQueue (circular doubly-linked list with sentinel)
[in]nodeNode 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 
)

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_qSource queue (node must be in this queue)
[in]to_qDestination queue
[in]nodeNode to move
Returns
The same node pointer (now in dest queue), or NULL on error