summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp4
-rw-r--r--src/core/hle/kernel/thread.cpp9
-rw-r--r--src/core/hle/kernel/thread.h15
-rw-r--r--src/core/hle/svc.cpp6
4 files changed, 16 insertions, 18 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index 2d01e2ef5..6e8f959f3 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -51,7 +51,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
case ArbitrationType::WaitIfLessThanWithTimeout:
if ((s32)Memory::Read32(address) <= value) {
Kernel::WaitCurrentThread_ArbitrateAddress(address);
- Kernel::WakeThreadAfterDelay(GetCurrentThread(), nanoseconds);
+ GetCurrentThread()->WakeAfterDelay(nanoseconds);
HLE::Reschedule(__func__);
}
break;
@@ -71,7 +71,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
Memory::Write32(address, memory_value);
if (memory_value <= value) {
Kernel::WaitCurrentThread_ArbitrateAddress(address);
- Kernel::WakeThreadAfterDelay(GetCurrentThread(), nanoseconds);
+ GetCurrentThread()->WakeAfterDelay(nanoseconds);
HLE::Reschedule(__func__);
}
break;
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 56950ebd4..1ea5589cb 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -248,14 +248,13 @@ static void ThreadWakeupCallback(u64 parameter, int cycles_late) {
}
-void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds) {
+void Thread::WakeAfterDelay(s64 nanoseconds) {
// Don't schedule a wakeup if the thread wants to wait forever
if (nanoseconds == -1)
return;
- _dbg_assert_(Kernel, thread != nullptr);
u64 microseconds = nanoseconds / 1000;
- CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, thread->GetHandle());
+ CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, GetHandle());
}
void Thread::ReleaseWaitObject(WaitObject* wait_object) {
@@ -418,7 +417,7 @@ void Thread::SetPriority(s32 priority) {
}
}
-Handle SetupIdleThread() {
+SharedPtr<Thread> SetupIdleThread() {
// We need to pass a few valid values to get around parameter checking in Thread::Create.
auto thread_res = Thread::Create("idle", Memory::KERNEL_MEMORY_VADDR, THREADPRIO_LOWEST, 0,
THREADPROCESSORID_0, 0, Kernel::DEFAULT_STACK_SIZE);
@@ -427,7 +426,7 @@ Handle SetupIdleThread() {
thread->idle = true;
CallThread(thread.get());
- return thread->GetHandle();
+ return thread;
}
SharedPtr<Thread> SetupMainThread(s32 priority, u32 stack_size) {
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index d6299364a..cba074e07 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -78,6 +78,12 @@ public:
void ResumeFromWait();
/**
+ * Schedules an event to wake up the specified thread after the specified delay.
+ * @param nanoseconds The time this thread will be allowed to sleep for.
+ */
+ void WakeAfterDelay(s64 nanoseconds);
+
+ /**
* Sets the result after the thread awakens (from either WaitSynchronization SVC)
* @param result Value to set to the returned result
*/
@@ -151,19 +157,12 @@ void WaitCurrentThread_WaitSynchronization(SharedPtr<WaitObject> wait_object, bo
void WaitCurrentThread_ArbitrateAddress(VAddr wait_address);
/**
- * Schedules an event to wake up the specified thread after the specified delay.
- * @param handle The thread handle.
- * @param nanoseconds The time this thread will be allowed to sleep for.
- */
-void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds);
-
-/**
* Sets up the idle thread, this is a thread that is intended to never execute instructions,
* only to advance the timing. It is scheduled when there are no other ready threads in the thread queue
* and will try to yield on every call.
* @returns The handle of the idle thread
*/
-Handle SetupIdleThread();
+SharedPtr<Thread> SetupIdleThread();
/// Initialize threading
void ThreadingInit();
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index d253f4fe5..1a0c07cb9 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -152,7 +152,7 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
Kernel::WaitCurrentThread_WaitSynchronization(object, false, false);
// Create an event to wake the thread up after the specified nanosecond delay has passed
- Kernel::WakeThreadAfterDelay(Kernel::GetCurrentThread(), nano_seconds);
+ Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds);
HLE::Reschedule(__func__);
@@ -228,7 +228,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
}
// Create an event to wake the thread up after the specified nanosecond delay has passed
- Kernel::WakeThreadAfterDelay(Kernel::GetCurrentThread(), nano_seconds);
+ Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds);
HLE::Reschedule(__func__);
@@ -540,7 +540,7 @@ static void SleepThread(s64 nanoseconds) {
Kernel::WaitCurrentThread_Sleep();
// Create an event to wake the thread up after the specified nanosecond delay has passed
- Kernel::WakeThreadAfterDelay(Kernel::GetCurrentThread(), nanoseconds);
+ Kernel::GetCurrentThread()->WakeAfterDelay(nanoseconds);
HLE::Reschedule(__func__);
}