mirror of
https://github.com/libretro/RetroArch
synced 2025-03-31 10:20:41 +00:00
commit
304e13ac16
@ -313,23 +313,20 @@ static scond_t *worker_cond = NULL;
|
|||||||
static sthread_t *worker_thread = NULL;
|
static sthread_t *worker_thread = NULL;
|
||||||
static bool worker_continue = true; /* use running_lock when touching it */
|
static bool worker_continue = true; /* use running_lock when touching it */
|
||||||
|
|
||||||
|
/* 'queue_lock' must be held for the duration of this function */
|
||||||
static void task_queue_remove(task_queue_t *queue, retro_task_t *task)
|
static void task_queue_remove(task_queue_t *queue, retro_task_t *task)
|
||||||
{
|
{
|
||||||
retro_task_t *t = NULL;
|
retro_task_t *t = NULL;
|
||||||
retro_task_t *front = NULL;
|
retro_task_t *front = NULL;
|
||||||
|
|
||||||
slock_lock(queue_lock);
|
|
||||||
front = queue->front;
|
front = queue->front;
|
||||||
slock_unlock(queue_lock);
|
|
||||||
|
|
||||||
/* Remove first element if needed */
|
/* Remove first element if needed */
|
||||||
if (task == front)
|
if (task == front)
|
||||||
{
|
{
|
||||||
slock_lock(queue_lock);
|
|
||||||
queue->front = task->next;
|
queue->front = task->next;
|
||||||
if (queue->back == task) /* if only element, also update back */
|
if (queue->back == task) /* if only element, also update back */
|
||||||
queue->back = NULL;
|
queue->back = NULL;
|
||||||
slock_unlock(queue_lock);
|
|
||||||
task->next = NULL;
|
task->next = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -348,10 +345,8 @@ static void task_queue_remove(task_queue_t *queue, retro_task_t *task)
|
|||||||
/* When removing the tail of the queue, update the tail pointer */
|
/* When removing the tail of the queue, update the tail pointer */
|
||||||
if (queue->back == task)
|
if (queue->back == task)
|
||||||
{
|
{
|
||||||
slock_lock(queue_lock);
|
|
||||||
if (queue->back == task)
|
if (queue->back == task)
|
||||||
queue->back = t;
|
queue->back = t;
|
||||||
slock_unlock(queue_lock);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -517,6 +512,7 @@ static void threaded_worker(void *userdata)
|
|||||||
{
|
{
|
||||||
task_queue_remove(&tasks_running, task);
|
task_queue_remove(&tasks_running, task);
|
||||||
task_queue_put(&tasks_running, task);
|
task_queue_put(&tasks_running, task);
|
||||||
|
scond_signal(worker_cond);
|
||||||
}
|
}
|
||||||
slock_unlock(queue_lock);
|
slock_unlock(queue_lock);
|
||||||
slock_unlock(running_lock);
|
slock_unlock(running_lock);
|
||||||
@ -525,7 +521,9 @@ static void threaded_worker(void *userdata)
|
|||||||
{
|
{
|
||||||
/* Remove task from running queue */
|
/* Remove task from running queue */
|
||||||
slock_lock(running_lock);
|
slock_lock(running_lock);
|
||||||
|
slock_lock(queue_lock);
|
||||||
task_queue_remove(&tasks_running, task);
|
task_queue_remove(&tasks_running, task);
|
||||||
|
slock_unlock(queue_lock);
|
||||||
slock_unlock(running_lock);
|
slock_unlock(running_lock);
|
||||||
|
|
||||||
/* Add task to finished queue */
|
/* Add task to finished queue */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user