diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-10-03 08:50:07 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-10-03 08:50:07 -0400 |
| commit | de65adbc1b2d1b3efdbe6a023bb7435f84b2f3a7 (patch) | |
| tree | 2851060d2cf464146d0fb67a50dc52f710076e05 /include/kpl/queue.h | |
| parent | 2e908a7be31558cc98a9f0e97556e49ee5748c16 (diff) | |
redesign
Diffstat (limited to 'include/kpl/queue.h')
| -rw-r--r-- | include/kpl/queue.h | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/include/kpl/queue.h b/include/kpl/queue.h deleted file mode 100644 index 0107434..0000000 --- a/include/kpl/queue.h +++ /dev/null @@ -1,53 +0,0 @@ - -#pragma once - -// KPL atomic queues - -#include "kpl/macro.h" - -typedef struct { - kpl_task *_Atomic head, *tail; - struct { - kpl_task *_Atomic next; - } dummy; -} kpl_task_queue; - -inline void kpl_task_queue_init(kpl_task_queue *task_queue) { - __atomic_store_n(&task_queue->dummy.next, NULL, __ATOMIC_RELAXED); - __atomic_store_n(&task_queue->head, &task_queue->dummy, __ATOMIC_RELAXED); - task_queue->tail = (kpl_task*) &task_queue->dummy; -} - -inline void kpl_task_queue_add(kpl_task_queue *task_queue, kpl_task *task) { - __atomic_store_n(&task->next, NULL, __ATOMIC_RELAXED); - kpl_task *head = __atomic_exchange_n(&task_queue->head, task, __ATOMIC_SEQ_CST); - __atomic_store_n(&head->next, task, __ATOMIC_RELEASE); -} - -kpl_task *kpl_task_queue_next(kpl_task_queue *task_queue); - -typedef enum : int8_t { - KPL_RING_QUEUE_MIN_POW2 = 4, - KPL_RING_QUEUE_MAX_POW2 = 30 -} kpl_ring_queue_pow2_sizes; - -typedef struct { - _Atomic ssize_t index; - void *data; -} kpl_ring_queue_item; - -typedef struct { - size_t mmap_size, items_mask; - _Atomic ssize_t head_index, tail_index; - kpl_ring_queue_item *items; -} kpl_ring_queue; - -bool kpl_ring_queue_init(kpl_ring_queue *ring_queue, int8_t size_pow2); - -inline void kpl_ring_queue_free(kpl_ring_queue *ring_queue) { - munmap(ring_queue->items, ring_queue->mmap_size); -} - -bool kpl_ring_queue_add(kpl_ring_queue *ring_queue, void *data); - -void *kpl_ring_queue_next(kpl_ring_queue *ring_queue); |
