mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 15:01:28 +12:00
Avoid copying std::shared_ptr in sys_semaphore
This commit is contained in:
parent
99895471ae
commit
675fde69aa
1 changed files with 6 additions and 3 deletions
|
@ -229,15 +229,18 @@ error_code sys_semaphore_post(ppu_thread& ppu, u32 sem_id, s32 count)
|
|||
{
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (val + s64{count} > sem->max)
|
||||
if (!ok)
|
||||
{
|
||||
return not_an_error(CELL_EBUSY);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue