Commit 07043f8d authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Simplify cMutex

parent 190a2582
Pipeline #19888 passed with stages
in 3 minutes and 17 seconds
......@@ -105,14 +105,14 @@ static int modem_read(struct pico_device *dev, void *data, int len)
u8 *p = (u8 *)data;
int count = 0;
out_buffer_lock.Lock();
out_buffer_lock.lock();
while (!out_buffer.empty() && count < len)
{
*p++ = out_buffer.front();
out_buffer.pop();
count++;
}
out_buffer_lock.Unlock();
out_buffer_lock.unlock();
return count;
}
......@@ -121,37 +121,37 @@ static int modem_write(struct pico_device *dev, const void *data, int len)
{
u8 *p = (u8 *)data;
in_buffer_lock.Lock();
in_buffer_lock.lock();
while (len > 0)
{
in_buffer.push(*p++);
len--;
}
in_buffer_lock.Unlock();
in_buffer_lock.unlock();
return len;
}
void write_pico(u8 b)
{
out_buffer_lock.Lock();
out_buffer_lock.lock();
out_buffer.push(b);
out_buffer_lock.Unlock();
out_buffer_lock.unlock();
}
int read_pico()
{
in_buffer_lock.Lock();
in_buffer_lock.lock();
if (in_buffer.empty())
{
in_buffer_lock.Unlock();
in_buffer_lock.unlock();
return -1;
}
else
{
u32 b = in_buffer.front();
in_buffer.pop();
in_buffer_lock.Unlock();
in_buffer_lock.unlock();
return b;
}
}
......@@ -455,9 +455,9 @@ static void read_native_sockets()
struct pico_msginfo msginfo;
// If modem buffer is full, wait
in_buffer_lock.Lock();
in_buffer_lock.lock();
size_t in_buffer_size = in_buffer.size();
in_buffer_lock.Unlock();
in_buffer_lock.unlock();
if (in_buffer_size >= 256)
return;
......
......@@ -85,7 +85,7 @@ bool TryDecodeTARC(void)
vd_ctx->rend.proc_start = vd_ctx->rend.proc_end + 32;
vd_ctx->rend.proc_end = vd_ctx->tad.thd_data;
vd_ctx->rend_inuse.Lock();
vd_ctx->rend_inuse.lock();
vd_rc = vd_ctx->rend;
//signal the vdec thread
......@@ -101,7 +101,7 @@ void VDecEnd(void)
vd_ctx->rend = vd_rc;
vd_ctx->rend_inuse.Unlock();
vd_ctx->rend_inuse.unlock();
vd_ctx = 0;
}
......@@ -155,10 +155,10 @@ bool QueueRender(TA_context* ctx)
}
frame_finished.Reset();
mtx_rqueue.Lock();
mtx_rqueue.lock();
TA_context* old = rqueue;
rqueue=ctx;
mtx_rqueue.Unlock();
mtx_rqueue.unlock();
verify(!old);
......@@ -167,9 +167,9 @@ bool QueueRender(TA_context* ctx)
TA_context* DequeueRender(void)
{
mtx_rqueue.Lock();
mtx_rqueue.lock();
TA_context* rv = rqueue;
mtx_rqueue.Unlock();
mtx_rqueue.unlock();
if (rv)
FrameCount++;
......@@ -179,9 +179,9 @@ TA_context* DequeueRender(void)
bool rend_framePending(void)
{
mtx_rqueue.Lock();
mtx_rqueue.lock();
TA_context* rv = rqueue;
mtx_rqueue.Unlock();
mtx_rqueue.unlock();
return rv != 0;
}
......@@ -191,9 +191,9 @@ void FinishRender(TA_context* ctx)
if (ctx != NULL)
{
verify(rqueue == ctx);
mtx_rqueue.Lock();
mtx_rqueue.lock();
rqueue = NULL;
mtx_rqueue.Unlock();
mtx_rqueue.unlock();
tactx_Recycle(ctx);
}
......@@ -210,13 +210,13 @@ TA_context* tactx_Alloc(void)
{
TA_context* rv = 0;
mtx_pool.Lock();
mtx_pool.lock();
if (!ctx_pool.empty())
{
rv = ctx_pool[ctx_pool.size()-1];
ctx_pool.pop_back();
}
mtx_pool.Unlock();
mtx_pool.unlock();
if (!rv)
{
......@@ -229,7 +229,7 @@ TA_context* tactx_Alloc(void)
void tactx_Recycle(TA_context* poped_ctx)
{
mtx_pool.Lock();
mtx_pool.lock();
if (ctx_pool.size()>2)
{
poped_ctx->Free();
......@@ -240,7 +240,7 @@ void tactx_Recycle(TA_context* poped_ctx)
poped_ctx->Reset();
ctx_pool.push_back(poped_ctx);
}
mtx_pool.Unlock();
mtx_pool.unlock();
}
TA_context* tactx_Find(u32 addr, bool allocnew)
......
......@@ -224,10 +224,10 @@ struct TA_context
void Reset()
{
tad.Clear();
rend_inuse.Lock();
rend_inuse.lock();
rend.Clear();
rend.proc_end = rend.proc_start = tad.thd_root;
rend_inuse.Unlock();
rend_inuse.unlock();
}
void Free()
......
......@@ -1631,7 +1631,7 @@ bool ta_parse_vdrc(TA_context* ctx)
vd_ctx->rend = vd_rc;
vd_ctx = 0;
ctx->rend_inuse.Unlock();
ctx->rend_inuse.unlock();
ctx->rend.Overrun = overrun;
......
......@@ -218,13 +218,13 @@ static void *emu_thread_func(void *)
while ( true )
{
performed_serialization = false ;
mtx_mainloop.Lock() ;
rend_cancel_emu_wait() ;
mtx_mainloop.lock();
rend_cancel_emu_wait();
dc_run();
mtx_mainloop.Unlock() ;
mtx_mainloop.unlock();
mtx_serialization.Lock() ;
mtx_serialization.Unlock() ;
mtx_serialization.lock();
mtx_serialization.unlock();
if (!performed_serialization && !reset_requested)
break ;
......@@ -235,7 +235,7 @@ static void *emu_thread_func(void *)
}
}
rend_cancel_emu_wait() ;
rend_cancel_emu_wait();
dc_term();
emu_in_thread = false ;
......@@ -350,8 +350,8 @@ void retro_deinit(void)
//When auto-save states are enabled this is needed to prevent the core from shutting down before
//any save state actions are still running - which results in partial saves
mtx_serialization.Lock() ;
mtx_serialization.Unlock() ;
mtx_serialization.lock();
mtx_serialization.unlock();
libretro_supports_bitmasks = false;
LogManager::Shutdown();
......@@ -1232,14 +1232,14 @@ void retro_run (void)
void retro_reset (void)
{
#if !defined(TARGET_NO_THREADS)
mtx_serialization.Lock();
mtx_serialization.lock();
if (settings.rend.ThreadedRendering)
{
dc_stop();
if (!acquire_mainloop_lock())
{
dc_start();
mtx_serialization.Unlock();
mtx_serialization.unlock();
return;
}
}
......@@ -1253,9 +1253,9 @@ void retro_reset (void)
if (settings.rend.ThreadedRendering)
{
performed_serialization = true;
mtx_mainloop.Unlock();
mtx_mainloop.unlock();
}
mtx_serialization.Unlock();
mtx_serialization.unlock();
#endif
}
......@@ -2100,7 +2100,7 @@ size_t retro_serialize_size (void)
bool wait_until_dc_running()
{
retro_time_t start_time = perf_cb.get_time_usec() ;
retro_time_t start_time = perf_cb.get_time_usec();
const retro_time_t FIVE_SECONDS = 5*1000000 ;
while(!dc_is_running())
{
......@@ -2116,10 +2116,10 @@ bool wait_until_dc_running()
bool acquire_mainloop_lock()
{
bool result = false ;
retro_time_t start_time = perf_cb.get_time_usec() ;
retro_time_t start_time = perf_cb.get_time_usec();
const retro_time_t FIVE_SECONDS = 5*1000000 ;
while ( ( start_time+FIVE_SECONDS > perf_cb.get_time_usec() ) && !(result = mtx_mainloop.TryLock()) )
while ( ( start_time+FIVE_SECONDS > perf_cb.get_time_usec() ) && !(result = mtx_mainloop.trylock()) )
{
rend_cancel_emu_wait();
}
......@@ -2134,19 +2134,20 @@ bool retro_serialize(void *data, size_t size)
bool result = false ;
#if !defined(TARGET_NO_THREADS)
mtx_serialization.Lock() ;
mtx_serialization.lock();
if (settings.rend.ThreadedRendering)
{
if ( !wait_until_dc_running()) {
mtx_serialization.Unlock() ;
if ( !wait_until_dc_running())
{
mtx_serialization.unlock();
return false ;
}
dc_stop() ;
if ( !acquire_mainloop_lock() )
dc_stop();
if ( !acquire_mainloop_lock())
{
dc_start() ;
mtx_serialization.Unlock() ;
dc_start();
mtx_serialization.unlock();
return false ;
}
}
......@@ -2158,9 +2159,9 @@ bool retro_serialize(void *data, size_t size)
#if !defined(TARGET_NO_THREADS)
if (settings.rend.ThreadedRendering)
{
mtx_mainloop.Unlock() ;
mtx_mainloop.unlock();
}
mtx_serialization.Unlock() ;
mtx_serialization.unlock();
#endif
return result ;
......@@ -2176,16 +2177,16 @@ bool retro_unserialize(const void * data, size_t size)
#if !defined(TARGET_NO_THREADS)
if (settings.rend.ThreadedRendering)
{
mtx_serialization.Lock() ;
mtx_serialization.lock();
if ( !wait_until_dc_running()) {
mtx_serialization.Unlock() ;
mtx_serialization.unlock();
return false ;
}
dc_stop() ;
if ( !acquire_mainloop_lock() )
dc_stop();
if ( !acquire_mainloop_lock())
{
dc_start() ;
mtx_serialization.Unlock() ;
dc_start();
mtx_serialization.unlock();
return false ;
}
}
......@@ -2219,8 +2220,8 @@ bool retro_unserialize(const void * data, size_t size)
#if !defined(TARGET_NO_THREADS)
if (settings.rend.ThreadedRendering)
{
mtx_mainloop.Unlock() ;
mtx_serialization.Unlock() ;
mtx_mainloop.unlock();
mtx_serialization.unlock();
}
#endif
......
......@@ -48,13 +48,13 @@ void CustomTexture::LoaderThread()
do {
texture = NULL;
work_queue_mutex.Lock();
work_queue_mutex.lock();
if (!work_queue.empty())
{
texture = work_queue.back();
work_queue.pop_back();
}
work_queue_mutex.Unlock();
work_queue_mutex.unlock();
if (texture != NULL)
{
......@@ -131,9 +131,9 @@ void CustomTexture::Terminate()
if (initialized)
{
initialized = false;
work_queue_mutex.Lock();
work_queue_mutex.lock();
work_queue.clear();
work_queue_mutex.Unlock();
work_queue_mutex.unlock();
wakeup_thread.Set();
loader_thread.WaitToEnd();
texture_map.clear();
......@@ -157,9 +157,9 @@ void CustomTexture::LoadCustomTextureAsync(BaseTextureCacheData *texture_data)
return;
texture_data->custom_load_in_progress++;
work_queue_mutex.Lock();
work_queue_mutex.lock();
work_queue.insert(work_queue.begin(), texture_data);
work_queue_mutex.Unlock();
work_queue_mutex.unlock();
wakeup_thread.Set();
}
......
......@@ -1065,7 +1065,7 @@ void rend_set_fb_scale(float x, float y)
bool ProcessFrame(TA_context* ctx)
{
ctx->rend_inuse.Lock();
ctx->rend_inuse.lock();
if (KillTex)
{
......@@ -1076,7 +1076,7 @@ bool ProcessFrame(TA_context* ctx)
if (ctx->rend.isRenderFramebuffer)
{
RenderFramebuffer();
ctx->rend_inuse.Unlock();
ctx->rend_inuse.unlock();
}
else
{
......
......@@ -84,7 +84,7 @@ public:
if (ctx->rend.isRenderFramebuffer)
return RenderFramebuffer();
ctx->rend_inuse.Lock();
ctx->rend_inuse.lock();
if (KillTex)
textureCache.Clear();
......
......@@ -214,13 +214,13 @@ public :
slock_free(mutx);
#endif
}
void Lock()
void lock()
{
#ifndef TARGET_NO_THREADS
slock_lock(mutx);
#endif
}
bool TryLock()
bool trylock()
{
#ifndef TARGET_NO_THREADS
return slock_try_lock(mutx);
......@@ -228,15 +228,12 @@ public :
return false;
#endif
}
void Unlock()
void unlock()
{
#ifndef TARGET_NO_THREADS
slock_unlock(mutx);
#endif
}
// std::BasicLockable so we can use std::lock_guard
void lock() { Lock(); }
void unlock() { Unlock(); }
};
//Set the path !
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment