Cleanup semaphore<> (sema.h) and mutex.h (shared_mutex)

Remove semaphore_lock and writer_lock classes, replace with std::lock_guard
Change semaphore<> interface to Lockable (+ exotic try_unlock method)
This commit is contained in:
Nekotekina 2018-09-03 22:28:33 +03:00
parent 5e556a87ff
commit ca5158a03e
50 changed files with 283 additions and 382 deletions

View file

@ -46,7 +46,7 @@ error_code _sys_lwmutex_destroy(u32 lwmutex_id)
const auto mutex = idm::withdraw<lv2_obj, lv2_lwmutex>(lwmutex_id, [&](lv2_lwmutex& mutex) -> CellError
{
semaphore_lock lock(mutex.mutex);
std::lock_guard lock(mutex.mutex);
if (!mutex.sq.empty())
{
@ -83,7 +83,7 @@ error_code _sys_lwmutex_lock(ppu_thread& ppu, u32 lwmutex_id, u64 timeout)
}
}
semaphore_lock lock(mutex.mutex);
std::lock_guard lock(mutex.mutex);
if (u32 value = mutex.signaled)
{
@ -118,7 +118,7 @@ error_code _sys_lwmutex_lock(ppu_thread& ppu, u32 lwmutex_id, u64 timeout)
if (passed >= timeout)
{
semaphore_lock lock(mutex->mutex);
std::lock_guard lock(mutex->mutex);
if (!mutex->unqueue(mutex->sq, &ppu))
{
@ -177,7 +177,7 @@ error_code _sys_lwmutex_unlock(ppu_thread& ppu, u32 lwmutex_id)
const auto mutex = idm::check<lv2_obj, lv2_lwmutex>(lwmutex_id, [&](lv2_lwmutex& mutex) -> cpu_thread*
{
semaphore_lock lock(mutex.mutex);
std::lock_guard lock(mutex.mutex);
if (const auto cpu = mutex.schedule<ppu_thread>(mutex.sq, mutex.protocol))
{