MCPcopy Create free account
hub / github.com/apache/trafficserver / remove_from_queue

Function remove_from_queue

example/plugins/c-api/thread_pool/thread.cc:80–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void *
81remove_from_queue(Queue *q)
82{
83 void *data = nullptr;
84 Cell *remove_cell;
85
86 TSMutexLock(q->mutex);
87 if (q->nb_elem > 0) {
88 remove_cell = q->head;
89 TSAssert(remove_cell->magic == MAGIC_ALIVE);
90
91 data = remove_cell->ptr_data;
92 q->head = remove_cell->ptr_prev;
93 if (q->head == nullptr) {
94 TSAssert(q->nb_elem == 1);
95 q->tail = nullptr;
96 } else {
97 TSAssert(q->head->magic == MAGIC_ALIVE);
98 q->head->ptr_next = nullptr;
99 }
100
101 remove_cell->magic = MAGIC_DEAD;
102 TSfree(remove_cell);
103 q->nb_elem--;
104 }
105 TSMutexUnlock(q->mutex);
106 return data;
107}
108
109int
110get_nbelem_queue(Queue *q)

Callers 1

thread_loopFunction · 0.85

Calls 3

TSMutexLockFunction · 0.85
TSfreeFunction · 0.85
TSMutexUnlockFunction · 0.85

Tested by

no test coverage detected