mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 00:34:03 +02:00
Try fixing a few issues with the lock-free queue.
This commit is contained in:
+4
-4
@@ -61603,7 +61603,7 @@ MA_API ma_result ma_resource_manager_job_queue_post(ma_resource_manager_job_queu
|
|||||||
/* The job is stored in memory so now we need to add it to our linked list. We only ever add items to the end of the list. */
|
/* The job is stored in memory so now we need to add it to our linked list. We only ever add items to the end of the list. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
tail = c89atomic_load_64(&pQueue->tail);
|
tail = c89atomic_load_64(&pQueue->tail);
|
||||||
next = pQueue->pJobs[ma_resource_manager_job_extract_slot(tail)].next;
|
next = c89atomic_load_64(&pQueue->pJobs[ma_resource_manager_job_extract_slot(tail)].next);
|
||||||
|
|
||||||
if (ma_resource_manager_job_toc_to_allocation(tail) == ma_resource_manager_job_toc_to_allocation(c89atomic_load_64(&pQueue->tail))) {
|
if (ma_resource_manager_job_toc_to_allocation(tail) == ma_resource_manager_job_toc_to_allocation(c89atomic_load_64(&pQueue->tail))) {
|
||||||
if (ma_resource_manager_job_extract_slot(next) == 0xFFFF) {
|
if (ma_resource_manager_job_extract_slot(next) == 0xFFFF) {
|
||||||
@@ -61661,17 +61661,17 @@ MA_API ma_result ma_resource_manager_job_queue_next(ma_resource_manager_job_queu
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
head = c89atomic_load_64(&pQueue->head);
|
head = c89atomic_load_64(&pQueue->head);
|
||||||
tail = c89atomic_load_64(&pQueue->tail);
|
tail = c89atomic_load_64(&pQueue->tail);
|
||||||
next = pQueue->pJobs[ma_resource_manager_job_extract_slot(head)].next;
|
next = c89atomic_load_64(&pQueue->pJobs[ma_resource_manager_job_extract_slot(head)].next);
|
||||||
|
|
||||||
if (ma_resource_manager_job_toc_to_allocation(head) == ma_resource_manager_job_toc_to_allocation(c89atomic_load_64(&pQueue->head))) {
|
if (ma_resource_manager_job_toc_to_allocation(head) == ma_resource_manager_job_toc_to_allocation(c89atomic_load_64(&pQueue->head))) {
|
||||||
if (ma_resource_manager_job_extract_slot(head) == ma_resource_manager_job_extract_slot(tail)) {
|
if (ma_resource_manager_job_extract_slot(head) == ma_resource_manager_job_extract_slot(tail)) {
|
||||||
if (ma_resource_manager_job_extract_slot(next) == 0xFFFF) {
|
if (ma_resource_manager_job_extract_slot(next) == 0xFFFF) {
|
||||||
return MA_NO_DATA_AVAILABLE;
|
return MA_NO_DATA_AVAILABLE;
|
||||||
}
|
}
|
||||||
ma_resource_manager_job_queue_cas(&pQueue->tail, tail, next);
|
ma_resource_manager_job_queue_cas(&pQueue->tail, tail, ma_resource_manager_job_extract_slot(next));
|
||||||
} else {
|
} else {
|
||||||
*pJob = pQueue->pJobs[ma_resource_manager_job_extract_slot(next)];
|
*pJob = pQueue->pJobs[ma_resource_manager_job_extract_slot(next)];
|
||||||
if (ma_resource_manager_job_queue_cas(&pQueue->head, head, next)) {
|
if (ma_resource_manager_job_queue_cas(&pQueue->head, head, ma_resource_manager_job_extract_slot(next))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user