mirror of
https://github.com/libretro/libretro-common.git
synced 2024-11-22 23:59:40 +00:00
Resync
This commit is contained in:
parent
b87eb93875
commit
4b71f9ee05
@ -93,6 +93,36 @@ typedef struct
|
||||
char *source_file;
|
||||
} decompress_task_data_t;
|
||||
|
||||
enum retro_task_flags
|
||||
{
|
||||
/**
|
||||
* If \c true, the frontend should use some alternative means
|
||||
* of displaying this task's progress or messages.
|
||||
* Not used within cores.
|
||||
*/
|
||||
RETRO_TASK_FLG_ALTERNATIVE_LOOK = (1 << 0),
|
||||
/**
|
||||
* Set to \c true by \c handler to indicate that this task has finished.
|
||||
* At this point the task queue will call \c callback and \c cleanup,
|
||||
* then deallocate the task.
|
||||
*/
|
||||
RETRO_TASK_FLG_FINISHED = (1 << 1),
|
||||
/**
|
||||
* Set to true by the task queue to signal that this task \em must end.
|
||||
* \c handler should check to see if this is set,
|
||||
* aborting or completing its work as soon as possible afterward.
|
||||
* \c callback and \c cleanup will still be called as normal.
|
||||
*
|
||||
* @see task_queue_reset
|
||||
*/
|
||||
RETRO_TASK_FLG_CANCELLED = (1 << 2),
|
||||
/**
|
||||
* If set, the task queue will not call \c progress_cb
|
||||
* and will not display any messages from this task.
|
||||
*/
|
||||
RETRO_TASK_FLG_MUTE = (1 << 3)
|
||||
};
|
||||
|
||||
/**
|
||||
* A unit of work executed by the task system,
|
||||
* spread across one or more frames.
|
||||
@ -245,35 +275,7 @@ struct retro_task
|
||||
enum task_type type;
|
||||
enum task_style style;
|
||||
|
||||
/**
|
||||
* If \c true, the frontend should use some alternative means
|
||||
* of displaying this task's progress or messages.
|
||||
* Not used within cores.
|
||||
*/
|
||||
bool alternative_look;
|
||||
|
||||
/**
|
||||
* Set to \c true by \c handler to indicate that this task has finished.
|
||||
* At this point the task queue will call \c callback and \c cleanup,
|
||||
* then deallocate the task.
|
||||
*/
|
||||
bool finished;
|
||||
|
||||
/**
|
||||
* Set to true by the task queue to signal that this task \em must end.
|
||||
* \c handler should check to see if this is set,
|
||||
* aborting or completing its work as soon as possible afterward.
|
||||
* \c callback and \c cleanup will still be called as normal.
|
||||
*
|
||||
* @see task_queue_reset
|
||||
*/
|
||||
bool cancelled;
|
||||
|
||||
/**
|
||||
* If set, the task queue will not call \c progress_cb
|
||||
* and will not display any messages from this task.
|
||||
*/
|
||||
bool mute;
|
||||
uint8_t flags;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -405,27 +407,7 @@ void task_queue_retriever_info_free(task_retriever_info_t *list);
|
||||
*/
|
||||
void task_queue_cancel_task(void *task);
|
||||
|
||||
/**
|
||||
* Sets \c task::finished to the given value.
|
||||
* Thread-safe if the task queue is threaded.
|
||||
*
|
||||
* @param task The task to modify.
|
||||
* Behavior is undefined if \c NULL.
|
||||
* @param finished Whether the task should be considered finished.
|
||||
* @see retro_task::finished
|
||||
*/
|
||||
void task_set_finished(retro_task_t *task, bool finished);
|
||||
|
||||
/**
|
||||
* Sets \c task::mute to the given value.
|
||||
* Thread-safe if the task queue is threaded.
|
||||
*
|
||||
* @param task The task to modify.
|
||||
* Behavior is undefined if \c NULL.
|
||||
* @param mute Whether the task should be considered muted.
|
||||
* @see retro_task::mute
|
||||
*/
|
||||
void task_set_mute(retro_task_t *task, bool mute);
|
||||
void task_set_flags(retro_task_t *task, uint8_t flags, bool set);
|
||||
|
||||
/**
|
||||
* Sets \c task::error to the given value.
|
||||
@ -476,17 +458,6 @@ void task_set_title(retro_task_t *task, char *title);
|
||||
*/
|
||||
void task_set_data(retro_task_t *task, void *data);
|
||||
|
||||
/**
|
||||
* Sets \c task::cancelled to the given value.
|
||||
* Thread-safe if the task queue is threaded.
|
||||
*
|
||||
* @param task The task to modify.
|
||||
* Behavior is undefined if \c NULL.
|
||||
* @param cancelled Whether the task should be considered cancelled.
|
||||
* @see retro_task::cancelled
|
||||
*/
|
||||
void task_set_cancelled(retro_task_t *task, bool cancelled);
|
||||
|
||||
/**
|
||||
* Frees the \c task's title, if any.
|
||||
* Thread-safe if the task queue is threaded.
|
||||
@ -496,39 +467,6 @@ void task_set_cancelled(retro_task_t *task, bool cancelled);
|
||||
*/
|
||||
void task_free_title(retro_task_t *task);
|
||||
|
||||
/**
|
||||
* Returns \c task::cancelled.
|
||||
* Thread-safe if the task queue is threaded.
|
||||
*
|
||||
* @param task The task to query.
|
||||
* Behavior is undefined if \c NULL.
|
||||
* @return The value of \c task::cancelled.
|
||||
* @see retro_task::cancelled
|
||||
*/
|
||||
bool task_get_cancelled(retro_task_t *task);
|
||||
|
||||
/**
|
||||
* Returns \c task::finished.
|
||||
* Thread-safe if the task queue is threaded.
|
||||
*
|
||||
* @param task The task to query.
|
||||
* Behavior is undefined if \c NULL.
|
||||
* @return The value of \c task::finished.
|
||||
* @see retro_task::finished
|
||||
*/
|
||||
bool task_get_finished(retro_task_t *task);
|
||||
|
||||
/**
|
||||
* Returns \c task::mute.
|
||||
* Thread-safe if the task queue is threaded.
|
||||
*
|
||||
* @param task The task to query.
|
||||
* Behavior is undefined if \c NULL.
|
||||
* @return The value of \c task::mute.
|
||||
* @see retro_task::mute
|
||||
*/
|
||||
bool task_get_mute(retro_task_t *task);
|
||||
|
||||
/**
|
||||
* Returns \c task::error.
|
||||
* Thread-safe if the task queue is threaded.
|
||||
@ -644,6 +582,8 @@ void task_queue_retrieve(task_retriever_data_t *data);
|
||||
*/
|
||||
void task_queue_check(void);
|
||||
|
||||
uint8_t task_get_flags(retro_task_t *task);
|
||||
|
||||
/**
|
||||
* Schedules a task to start running.
|
||||
* If \c task::when is 0, it will start as soon as possible.
|
||||
|
@ -98,9 +98,9 @@ static void task_queue_push_progress(retro_task_t *task)
|
||||
slock_lock(property_lock);
|
||||
#endif
|
||||
|
||||
if (task->title && !task->mute)
|
||||
if (task->title && (!((task->flags & RETRO_TASK_FLG_MUTE) > 0)))
|
||||
{
|
||||
if (task->finished)
|
||||
if ((task->flags & RETRO_TASK_FLG_FINISHED) > 0)
|
||||
{
|
||||
if (task->error)
|
||||
task_queue_msg_push(task, 1, 60, true, "%s: %s",
|
||||
@ -205,7 +205,7 @@ static void retro_task_regular_push_running(retro_task_t *task)
|
||||
static void retro_task_regular_cancel(void *task)
|
||||
{
|
||||
retro_task_t *t = (retro_task_t*)task;
|
||||
t->cancelled = true;
|
||||
t->flags |= RETRO_TASK_FLG_CANCELLED;
|
||||
}
|
||||
|
||||
static void retro_task_regular_gather(void)
|
||||
@ -231,7 +231,7 @@ static void retro_task_regular_gather(void)
|
||||
task_queue_push_progress(task);
|
||||
}
|
||||
|
||||
if (task->finished)
|
||||
if ((task->flags & RETRO_TASK_FLG_FINISHED) > 0)
|
||||
task_queue_put(&tasks_finished, task);
|
||||
else
|
||||
task_queue_put(&tasks_running, task);
|
||||
@ -251,7 +251,7 @@ static void retro_task_regular_reset(void)
|
||||
retro_task_t *task = tasks_running.front;
|
||||
|
||||
for (; task; task = task->next)
|
||||
task->cancelled = true;
|
||||
task->flags |= RETRO_TASK_FLG_CANCELLED;
|
||||
}
|
||||
|
||||
static void retro_task_regular_init(void) { }
|
||||
@ -391,7 +391,7 @@ static void retro_task_threaded_cancel(void *task)
|
||||
{
|
||||
if (t == task)
|
||||
{
|
||||
t->cancelled = true;
|
||||
t->flags |= RETRO_TASK_FLG_CANCELLED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -440,7 +440,7 @@ static void retro_task_threaded_reset(void)
|
||||
|
||||
slock_lock(running_lock);
|
||||
for (task = tasks_running.front; task; task = task->next)
|
||||
task->cancelled = true;
|
||||
task->flags |= RETRO_TASK_FLG_CANCELLED;
|
||||
slock_unlock(running_lock);
|
||||
}
|
||||
|
||||
@ -511,7 +511,7 @@ static void threaded_worker(void *userdata)
|
||||
task->handler(task);
|
||||
|
||||
slock_lock(property_lock);
|
||||
finished = task->finished;
|
||||
finished = ((task->flags & RETRO_TASK_FLG_FINISHED) > 0) ? true : false;
|
||||
slock_unlock(property_lock);
|
||||
|
||||
/* Update queue */
|
||||
@ -762,28 +762,6 @@ bool task_is_on_main_thread(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void task_set_finished(retro_task_t *task, bool finished)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
slock_lock(property_lock);
|
||||
#endif
|
||||
task->finished = finished;
|
||||
#ifdef HAVE_THREADS
|
||||
slock_unlock(property_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
void task_set_mute(retro_task_t *task, bool mute)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
slock_lock(property_lock);
|
||||
#endif
|
||||
task->mute = mute;
|
||||
#ifdef HAVE_THREADS
|
||||
slock_unlock(property_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
void task_set_error(retro_task_t *task, char *error)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
@ -828,17 +806,6 @@ void task_set_data(retro_task_t *task, void *data)
|
||||
#endif
|
||||
}
|
||||
|
||||
void task_set_cancelled(retro_task_t *task, bool cancelled)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
slock_lock(running_lock);
|
||||
#endif
|
||||
task->cancelled = cancelled;
|
||||
#ifdef HAVE_THREADS
|
||||
slock_unlock(running_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
void task_free_title(retro_task_t *task)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
@ -867,49 +834,31 @@ void* task_get_data(retro_task_t *task)
|
||||
return data;
|
||||
}
|
||||
|
||||
bool task_get_cancelled(retro_task_t *task)
|
||||
void task_set_flags(retro_task_t *task, uint8_t flags, bool set)
|
||||
{
|
||||
bool cancelled = false;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
slock_lock(running_lock);
|
||||
#endif
|
||||
cancelled = task->cancelled;
|
||||
#ifdef HAVE_THREADS
|
||||
slock_unlock(running_lock);
|
||||
#endif
|
||||
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
bool task_get_finished(retro_task_t *task)
|
||||
{
|
||||
bool finished = false;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
slock_lock(property_lock);
|
||||
#endif
|
||||
finished = task->finished;
|
||||
if (set)
|
||||
task->flags |= (flags);
|
||||
else
|
||||
task->flags &= ~(flags);
|
||||
#ifdef HAVE_THREADS
|
||||
slock_unlock(property_lock);
|
||||
#endif
|
||||
|
||||
return finished;
|
||||
}
|
||||
|
||||
bool task_get_mute(retro_task_t *task)
|
||||
uint8_t task_get_flags(retro_task_t *task)
|
||||
{
|
||||
bool mute = false;
|
||||
|
||||
uint8_t _flags = 0;
|
||||
#ifdef HAVE_THREADS
|
||||
slock_lock(property_lock);
|
||||
#endif
|
||||
mute = task->mute;
|
||||
_flags = task->flags;
|
||||
#ifdef HAVE_THREADS
|
||||
slock_unlock(property_lock);
|
||||
#endif
|
||||
|
||||
return mute;
|
||||
return _flags;
|
||||
}
|
||||
|
||||
char* task_get_error(retro_task_t *task)
|
||||
@ -969,9 +918,7 @@ retro_task_t *task_init(void)
|
||||
task->handler = NULL;
|
||||
task->callback = NULL;
|
||||
task->cleanup = NULL;
|
||||
task->finished = false;
|
||||
task->cancelled = false;
|
||||
task->mute = false;
|
||||
task->flags = 0;
|
||||
task->task_data = NULL;
|
||||
task->user_data = NULL;
|
||||
task->state = NULL;
|
||||
@ -983,7 +930,6 @@ retro_task_t *task_init(void)
|
||||
task->style = TASK_STYLE_NONE;
|
||||
task->ident = task_count++;
|
||||
task->frontend_userdata = NULL;
|
||||
task->alternative_look = false;
|
||||
task->next = NULL;
|
||||
task->when = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user