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

Function add_to_queue

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

Source from the content-addressed store, hash-verified

46}
47
48void
49add_to_queue(Queue *q, void *data)
50{
51 if (data != nullptr) {
52 TSMutexLock(q->mutex);
53 /* Init the new cell */
54 auto new_cell = TSRalloc<Cell>();
55 new_cell->magic = MAGIC_ALIVE;
56 new_cell->ptr_data = data;
57 new_cell->ptr_next = q->tail;
58 new_cell->ptr_prev = nullptr;
59
60 /* Add this new cell to the queue */
61 if (q->tail == nullptr) {
62 TSAssert(q->head == nullptr);
63 TSAssert(q->nb_elem == 0);
64 q->tail = new_cell;
65 q->head = new_cell;
66 } else {
67 TSAssert(q->tail->magic == MAGIC_ALIVE);
68 q->tail->ptr_prev = new_cell;
69 q->tail = new_cell;
70 }
71 int n = q->nb_elem++;
72 TSMutexUnlock(q->mutex);
73
74 if (n > MAX_JOBS_ALARM) {
75 TSError("[%s] Warning:Too many jobs in plugin thread pool queue (%d). Maximum allowed is %d", PLUGIN_NAME, n, MAX_JOBS_ALARM);
76 }
77 }
78}
79
80void *
81remove_from_queue(Queue *q)

Callers 1

handle_transformFunction · 0.85

Calls 3

TSMutexLockFunction · 0.85
TSMutexUnlockFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected