autosave_lock/autosave_unlock - no longer require HAVE_THREADS ifdefs

This commit is contained in:
twinaphex 2016-10-04 09:56:58 +02:00
parent b3d4fe398b
commit 19863e4174
4 changed files with 36 additions and 50 deletions

View File

@ -239,13 +239,9 @@ static void netplay_net_post_frame(netplay_t *netplay)
if (netplay->replay_frame_count >= netplay->read_frame_count)
netplay_simulate_input(netplay, netplay->replay_ptr);
#if defined(HAVE_THREADS)
autosave_lock();
#endif
core_run();
#if defined(HAVE_THREADS)
autosave_unlock();
#endif
netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr);
netplay->replay_frame_count++;
}

View File

@ -205,13 +205,9 @@ static void netplay_spectate_post_frame(netplay_t *netplay)
while (netplay->replay_frame_count < netplay->self_frame_count)
{
#if defined(HAVE_THREADS)
autosave_lock();
#endif
core_run();
#if defined(HAVE_THREADS)
autosave_unlock();
#endif
netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr);
netplay->replay_frame_count++;
}
@ -242,13 +238,9 @@ static void netplay_spectate_post_frame(netplay_t *netplay)
while (netplay->replay_frame_count < netplay->read_frame_count - 1)
{
#if defined(HAVE_THREADS)
autosave_lock();
#endif
core_run();
#if defined(HAVE_THREADS)
autosave_unlock();
#endif
netplay->replay_ptr = NEXT_PTR(netplay->replay_ptr);
netplay->replay_frame_count++;
@ -268,10 +260,7 @@ static bool netplay_spectate_info_cb(netplay_t* netplay, unsigned frames)
{
int i;
for (i = 0; i < MAX_SPECTATORS; i++)
{
netplay->spectate.fds[i] = -1;
}
}
else
{

View File

@ -1328,9 +1328,7 @@ int runloop_iterate(unsigned *sleep_ms)
return 1;
}
#if defined(HAVE_THREADS)
autosave_lock();
#endif
#ifdef HAVE_NETWORKING
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_PRE_FRAME, NULL))
@ -1385,9 +1383,7 @@ int runloop_iterate(unsigned *sleep_ms)
netplay_driver_ctl(RARCH_NETPLAY_CTL_POST_FRAME, NULL);
#endif
#if defined(HAVE_THREADS)
autosave_unlock();
#endif
if (!settings->fastforward_ratio)
return 0;

View File

@ -258,37 +258,6 @@ static void autosave_free(autosave_t *handle)
free(handle);
}
/**
* autosave_lock:
*
* Lock autosave.
**/
void autosave_lock(void)
{
unsigned i;
for (i = 0; i < autosave_state.num; i++)
{
if (autosave_state.list[i])
slock_lock(autosave_state.list[i]->lock);
}
}
/**
* autosave_unlock:
*
* Unlocks autosave.
**/
void autosave_unlock(void)
{
unsigned i;
for (i = 0; i < autosave_state.num; i++)
{
if (autosave_state.list[i])
slock_unlock(autosave_state.list[i]->lock);
}
}
void autosave_init(void)
{
@ -345,6 +314,42 @@ void autosave_deinit(void)
}
#endif
/**
* autosave_lock:
*
* Lock autosave.
**/
void autosave_lock(void)
{
#ifdef HAVE_THREADS
unsigned i;
for (i = 0; i < autosave_state.num; i++)
{
if (autosave_state.list[i])
slock_lock(autosave_state.list[i]->lock);
}
#endif
}
/**
* autosave_unlock:
*
* Unlocks autosave.
**/
void autosave_unlock(void)
{
#ifdef HAVE_THREADS
unsigned i;
for (i = 0; i < autosave_state.num; i++)
{
if (autosave_state.list[i])
slock_unlock(autosave_state.list[i]->lock);
}
#endif
}
/**
* undo_load_state:
* Revert to the state before a state was loaded.