| 46 | } |
| 47 | |
| 48 | void |
| 49 | add_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 | |
| 80 | void * |
| 81 | remove_from_queue(Queue *q) |
no test coverage detected