#ifndef CORE_JOB_H #define CORE_JOB_H // NOTE: multi producer / multi consumer deque of u32 job ids. used by the download pool. // push_back is the bulk lane (--sync, "download all"), push_front is the urgent lane (the track // you just pressed play on). a ring of plain u32s so popping is one cache line touch. typedef struct JobQueue JobQueue; struct JobQueue { CacheAligned SpinLock lock; u32 head; // index of the front item u32 count; u32 capacity; u32 mask; u32 *items; CacheAligned Signal signal; // bumped on every push and on quit u32 quit; }; internal void job_queue_init(Arena *arena, JobQueue *queue, u32 capacity_pow2); internal b32 job_queue_push_back(JobQueue *queue, u32 item); internal b32 job_queue_push_front(JobQueue *queue, u32 item); internal b32 job_queue_pop(JobQueue *queue, u32 *out); // blocks, false once quit internal u32 job_queue_count(JobQueue *queue); internal void job_queue_quit(JobQueue *queue); #endif // CORE_JOB_H