@@ -1116,15 +1116,33 @@ The slot index is stored in the low 32 bits. The reference counter is stored in
*/
typedefstruct
{
struct
{
MA_ATOMICma_uint32bitfield;/* Must be used atomically because the allocation and freeing routines need to make copies of this which must never be optimized away by the compiler. */
MA_ATOMICma_uint32bitfield;/* Must be used atomically because the allocation and freeing routines need to make copies of this which must never be optimized away by the compiler. */
}ma_slot_allocator_group;
typedefstruct
{
ma_slot_allocator_group*pGroups;/* Slots are grouped in chunks of 32. */
ma_uint32*pSlots;/* 32 bits for reference counting for ABA mitigation. */
MA_APIma_resultma_resource_manager_job_queue_next(ma_resource_manager_job_queue*pQueue,ma_resource_manager_job*pJob);/* Returns MA_CANCELLED if the next job is a quit job. */
/* We weren't able to find a slot. If it's because we've reached our capacity we need to return MA_OUT_OF_MEMORY. Otherwise we need to do another iteration and try again. */
Lock free queue implementation based on the paper by Michael and Scott: Nonblocking Algorithms and Preemption-Safe Locking on Multiprogrammed Shared Memory Multiprocessors