mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-17 18:37:34 +01:00
WaitSynchronizationN: Handle case where handle_count=0.
This commit is contained in:
parent
7faf2d8e06
commit
064be2b86f
@ -148,27 +148,37 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
|
|||||||
bool wait_all_succeeded = false;
|
bool wait_all_succeeded = false;
|
||||||
int handle_index = 0;
|
int handle_index = 0;
|
||||||
|
|
||||||
while (handle_index < handle_count) {
|
// If handles were passed in, iterate through them and wait/acquire the objects as needed
|
||||||
SharedPtr<Kernel::Object> object = Kernel::g_handle_table.GetGeneric(handles[handle_index]);
|
if (handle_count > 0) {
|
||||||
if (object == nullptr)
|
while (handle_index < handle_count) {
|
||||||
return InvalidHandle(ErrorModule::Kernel).raw;
|
SharedPtr<Kernel::Object> object = Kernel::g_handle_table.GetGeneric(handles[handle_index]);
|
||||||
|
if (object == nullptr)
|
||||||
|
return InvalidHandle(ErrorModule::Kernel).raw;
|
||||||
|
|
||||||
ResultVal<bool> wait = object->WaitSynchronization(handle_index);
|
ResultVal<bool> wait = object->WaitSynchronization(handle_index);
|
||||||
|
|
||||||
wait_thread = (wait.Succeeded() && *wait);
|
wait_thread = (wait.Succeeded() && *wait);
|
||||||
|
|
||||||
// If this object waited and we are waiting on all objects to synchronize
|
// If this object waited and we are waiting on all objects to synchronize
|
||||||
if (wait_thread && wait_all) {
|
if (wait_thread && wait_all) {
|
||||||
// Enforce later on that this thread does not continue
|
// Enforce later on that this thread does not continue
|
||||||
wait_all_succeeded = true;
|
wait_all_succeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this object synchronized and we are not waiting on all objects to synchronize
|
||||||
|
if (!wait_thread && !wait_all)
|
||||||
|
// We're done, the thread will continue
|
||||||
|
break;
|
||||||
|
|
||||||
|
handle_index++;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
// If no handles were passed in, put the thread to sleep only when wait_all=false
|
||||||
|
// NOTE: This is supposed to deadlock if no timeout was specified
|
||||||
|
if (!wait_all) {
|
||||||
|
wait_thread = true;
|
||||||
|
Kernel::WaitCurrentThread(WAITTYPE_SLEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this object synchronized and we are not waiting on all objects to synchronize
|
|
||||||
if (!wait_thread && !wait_all)
|
|
||||||
// We're done, the thread will continue
|
|
||||||
break;
|
|
||||||
|
|
||||||
handle_index++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the thread state to waiting if blocking on all handles...
|
// Change the thread state to waiting if blocking on all handles...
|
||||||
|
Loading…
Reference in New Issue
Block a user