only wait for save task to complete

This commit is contained in:
Jamiras 2020-07-10 19:39:13 -06:00
parent 5ebce6a238
commit 9aa42c9d5e
4 changed files with 12 additions and 9 deletions

View File

@ -51,8 +51,8 @@ bool content_load_state(const char* path, bool load_to_backup_buffer, bool autol
/* Save a state from memory to disk. */
bool content_save_state(const char *path, bool save_to_disk, bool autosave);
/* Returns true if a save state task is in progress */
bool content_save_state_in_progress(void);
/* Waits for any in-progress save state tasks to finish */
void content_wait_for_save_state_task(void);
/* Copy a save state. */
bool content_rename_state(const char *origin, const char *dest);

View File

@ -235,7 +235,7 @@ static void retro_task_regular_gather(void)
static void retro_task_regular_wait(retro_task_condition_fn_t cond, void* data)
{
while (tasks_running.front && (!cond || cond(data)))
while ((tasks_running.front && !tasks_running.front->when) && (!cond || cond(data)))
retro_task_regular_gather();
}
@ -420,10 +420,9 @@ static void retro_task_threaded_wait(retro_task_condition_fn_t cond, void* data)
retro_task_threaded_gather();
slock_lock(running_lock);
wait = (tasks_running.front) &&
(!cond || cond(data));
wait = (tasks_running.front && !tasks_running.front->when);
slock_unlock(running_lock);
} while (wait);
} while (wait && (!cond || cond(data)));
}
static void retro_task_threaded_reset(void)

View File

@ -37605,8 +37605,7 @@ bool retroarch_main_quit(void)
/* If any save states are in progress, wait
* until all tasks are complete (otherwise
* save state file may be truncated) */
if (content_save_state_in_progress())
task_queue_wait(NULL, NULL);
content_wait_for_save_state_task();
#ifdef HAVE_CONFIGFILE
if (p_rarch->runloop_overrides_active)

View File

@ -1372,7 +1372,7 @@ static bool task_save_state_finder(retro_task_t *task, void *user_data)
}
/* Returns true if a save state task is in progress */
bool content_save_state_in_progress(void)
static bool content_save_state_in_progress(void* data)
{
task_finder_data_t find_data;
@ -1385,6 +1385,11 @@ bool content_save_state_in_progress(void)
return false;
}
void content_wait_for_save_state_task(void)
{
task_queue_wait(content_save_state_in_progress, NULL);
}
/**
* content_load_state:
* @path : path that state will be loaded from.