From c8c05306a327eb7da62f8e61ebfceab5498d398e Mon Sep 17 00:00:00 2001 From: Jamiras Date: Sat, 22 Feb 2020 12:59:42 -0700 Subject: [PATCH] add comments --- libretro-common/queues/task_queue.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 69e374d7dd..6833f1bfbf 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -115,6 +115,10 @@ static void task_queue_put(task_queue_t *queue, retro_task_t *task) if (queue->front) { + /* Make sure to insert in order - the queue is sorted by 'when' so items that aren't scheduled + * to run immediately are at the back of the queue. Items with the same 'when' are inserted after + * all the other items with the same 'when'. This primarily affects items with a 'when' of 0. + */ if (queue->back->when > task->when) { retro_task_t** prev = &queue->front; @@ -341,6 +345,7 @@ static void task_queue_remove(task_queue_t *queue, retro_task_t *task) t->next = task->next; task->next = NULL; + /* When removing the tail of the queue, update the tail pointer */ if (queue->back == task) { slock_lock(queue_lock);