mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-23 03:02:53 +01:00
Avoid copying std::shared_ptr in sys_semaphore
This commit is contained in:
parent
99895471ae
commit
675fde69aa
@ -229,15 +229,18 @@ error_code sys_semaphore_post(ppu_thread& ppu, u32 sem_id, s32 count)
|
|||||||
{
|
{
|
||||||
std::lock_guard lock(sem->mutex);
|
std::lock_guard lock(sem->mutex);
|
||||||
|
|
||||||
const s32 val = sem->val.fetch_op([=](s32& val)
|
const auto [val, ok] = sem->val.fetch_op([&](s32& val)
|
||||||
{
|
{
|
||||||
if (val + s64{count} <= sem->max)
|
if (count + 0u <= sem->max + 0u - val)
|
||||||
{
|
{
|
||||||
val += count;
|
val += count;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (val + s64{count} > sem->max)
|
if (!ok)
|
||||||
{
|
{
|
||||||
return not_an_error(CELL_EBUSY);
|
return not_an_error(CELL_EBUSY);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user