mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 03:41:03 +00:00
Thread: Remove the last Handle-based interfaces from Thread.cpp
This commit is contained in:
parent
5619e790b8
commit
c91d2e959b
@ -40,11 +40,11 @@ ResultCode ArbitrateAddress(Handle handle, ArbitrationType type, u32 address, s3
|
|||||||
case ArbitrationType::Signal:
|
case ArbitrationType::Signal:
|
||||||
// Negative value means resume all threads
|
// Negative value means resume all threads
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
ArbitrateAllThreads(handle, address);
|
ArbitrateAllThreads(object, address);
|
||||||
} else {
|
} else {
|
||||||
// Resume first N threads
|
// Resume first N threads
|
||||||
for(int i = 0; i < value; i++)
|
for(int i = 0; i < value; i++)
|
||||||
ArbitrateHighestPriorityThread(handle, address);
|
ArbitrateHighestPriorityThread(object, address);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -152,39 +152,38 @@ void ChangeThreadState(Thread* t, ThreadStatus new_status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Arbitrate the highest priority thread that is waiting
|
/// Arbitrate the highest priority thread that is waiting
|
||||||
Handle ArbitrateHighestPriorityThread(Handle arbiter, u32 address) {
|
Thread* ArbitrateHighestPriorityThread(Object* arbiter, u32 address) {
|
||||||
Handle highest_priority_thread = 0;
|
Thread* highest_priority_thread = nullptr;
|
||||||
s32 priority = THREADPRIO_LOWEST;
|
s32 priority = THREADPRIO_LOWEST;
|
||||||
|
|
||||||
// Iterate through threads, find highest priority thread that is waiting to be arbitrated...
|
// Iterate through threads, find highest priority thread that is waiting to be arbitrated...
|
||||||
for (Thread* thread : thread_queue) {
|
for (Thread* thread : thread_queue) {
|
||||||
if (!CheckWaitType(thread, WAITTYPE_ARB, Kernel::g_handle_table.GetGeneric(arbiter), address))
|
if (!CheckWaitType(thread, WAITTYPE_ARB, arbiter, address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (thread == nullptr)
|
if (thread == nullptr)
|
||||||
continue; // TODO(yuriks): Thread handle will hang around forever. Should clean up.
|
continue; // TODO(yuriks): Thread handle will hang around forever. Should clean up.
|
||||||
|
|
||||||
if(thread->current_priority <= priority) {
|
if(thread->current_priority <= priority) {
|
||||||
highest_priority_thread = thread->GetHandle();
|
highest_priority_thread = thread;
|
||||||
priority = thread->current_priority;
|
priority = thread->current_priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a thread was arbitrated, resume it
|
// If a thread was arbitrated, resume it
|
||||||
if (0 != highest_priority_thread) {
|
if (nullptr != highest_priority_thread) {
|
||||||
Thread* thread = Kernel::g_handle_table.Get<Thread>(highest_priority_thread);
|
highest_priority_thread->ResumeFromWait();
|
||||||
if (thread != nullptr)
|
|
||||||
thread->ResumeFromWait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return highest_priority_thread;
|
return highest_priority_thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Arbitrate all threads currently waiting
|
/// Arbitrate all threads currently waiting
|
||||||
void ArbitrateAllThreads(Handle arbiter, u32 address) {
|
void ArbitrateAllThreads(Object* arbiter, u32 address) {
|
||||||
|
|
||||||
// Iterate through threads, find highest priority thread that is waiting to be arbitrated...
|
// Iterate through threads, find highest priority thread that is waiting to be arbitrated...
|
||||||
for (Thread* thread : thread_queue) {
|
for (Thread* thread : thread_queue) {
|
||||||
if (CheckWaitType(thread, WAITTYPE_ARB, Kernel::g_handle_table.GetGeneric(arbiter), address))
|
if (CheckWaitType(thread, WAITTYPE_ARB, arbiter, address))
|
||||||
thread->ResumeFromWait();
|
thread->ResumeFromWait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,10 @@ Thread* SetupMainThread(s32 priority, int stack_size = Kernel::DEFAULT_STACK_SIZ
|
|||||||
void Reschedule();
|
void Reschedule();
|
||||||
|
|
||||||
/// Arbitrate the highest priority thread that is waiting
|
/// Arbitrate the highest priority thread that is waiting
|
||||||
Handle ArbitrateHighestPriorityThread(Handle arbiter, u32 address);
|
Thread* ArbitrateHighestPriorityThread(Object* arbiter, u32 address);
|
||||||
|
|
||||||
/// Arbitrate all threads currently waiting...
|
/// Arbitrate all threads currently waiting...
|
||||||
void ArbitrateAllThreads(Handle arbiter, u32 address);
|
void ArbitrateAllThreads(Object* arbiter, u32 address);
|
||||||
|
|
||||||
/// Gets the current thread
|
/// Gets the current thread
|
||||||
Thread* GetCurrentThread();
|
Thread* GetCurrentThread();
|
||||||
|
Loading…
Reference in New Issue
Block a user