Merge pull request #2967 from Subv/thread_wakeup_callbacks
Kernel/Threads: When putting a thread to wait, specify a function to execute when it is awoken
This commit is contained in:
commit
db752b52e8
4 changed files with 91 additions and 17 deletions
|
@ -71,23 +71,20 @@ void WaitObject::WakeupAllWaitingThreads() {
|
|||
while (auto thread = GetHighestPriorityReadyThread()) {
|
||||
if (!thread->IsSleepingOnWaitAll()) {
|
||||
Acquire(thread.get());
|
||||
// Set the output index of the WaitSynchronizationN call to the index of this object.
|
||||
if (thread->wait_set_output) {
|
||||
thread->SetWaitSynchronizationOutput(thread->GetWaitObjectIndex(this));
|
||||
thread->wait_set_output = false;
|
||||
}
|
||||
} else {
|
||||
for (auto& object : thread->wait_objects) {
|
||||
object->Acquire(thread.get());
|
||||
}
|
||||
// Note: This case doesn't update the output index of WaitSynchronizationN.
|
||||
}
|
||||
|
||||
// Invoke the wakeup callback before clearing the wait objects
|
||||
if (thread->wakeup_callback)
|
||||
thread->wakeup_callback(ThreadWakeupReason::Signal, thread, this);
|
||||
|
||||
for (auto& object : thread->wait_objects)
|
||||
object->RemoveWaitingThread(thread.get());
|
||||
thread->wait_objects.clear();
|
||||
|
||||
thread->SetWaitSynchronizationResult(RESULT_SUCCESS);
|
||||
thread->ResumeFromWait();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue