diff options
| author | 2015-01-30 23:07:54 -0200 | |
|---|---|---|
| committer | 2015-02-02 15:37:01 -0200 | |
| commit | 664c79ff47054df845096e7e29d5cc437dfec2a2 (patch) | |
| tree | 1ebd682a7e75c964f2ac98f2dffbc5adba037442 /src/core | |
| parent | Service: Store function names as const char* instead of std::string (diff) | |
| download | yuzu-664c79ff47054df845096e7e29d5cc437dfec2a2.tar.gz yuzu-664c79ff47054df845096e7e29d5cc437dfec2a2.tar.xz yuzu-664c79ff47054df845096e7e29d5cc437dfec2a2.zip | |
Thread: Modernize two functions that slipped through previous rebases
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 15 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 6 |
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, | |||
| 51 | case ArbitrationType::WaitIfLessThanWithTimeout: | 51 | case ArbitrationType::WaitIfLessThanWithTimeout: |
| 52 | if ((s32)Memory::Read32(address) <= value) { | 52 | if ((s32)Memory::Read32(address) <= value) { |
| 53 | Kernel::WaitCurrentThread_ArbitrateAddress(address); | 53 | Kernel::WaitCurrentThread_ArbitrateAddress(address); |
| 54 | Kernel::WakeThreadAfterDelay(GetCurrentThread(), nanoseconds); | 54 | GetCurrentThread()->WakeAfterDelay(nanoseconds); |
| 55 | HLE::Reschedule(__func__); | 55 | HLE::Reschedule(__func__); |
| 56 | } | 56 | } |
| 57 | break; | 57 | break; |
| @@ -71,7 +71,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address, | |||
| 71 | Memory::Write32(address, memory_value); | 71 | Memory::Write32(address, memory_value); |
| 72 | if (memory_value <= value) { | 72 | if (memory_value <= value) { |
| 73 | Kernel::WaitCurrentThread_ArbitrateAddress(address); | 73 | Kernel::WaitCurrentThread_ArbitrateAddress(address); |
| 74 | Kernel::WakeThreadAfterDelay(GetCurrentThread(), nanoseconds); | 74 | GetCurrentThread()->WakeAfterDelay(nanoseconds); |
| 75 | HLE::Reschedule(__func__); | 75 | HLE::Reschedule(__func__); |
| 76 | } | 76 | } |
| 77 | break; | 77 | 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) { | |||
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | 250 | ||
| 251 | void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds) { | 251 | void Thread::WakeAfterDelay(s64 nanoseconds) { |
| 252 | // Don't schedule a wakeup if the thread wants to wait forever | 252 | // Don't schedule a wakeup if the thread wants to wait forever |
| 253 | if (nanoseconds == -1) | 253 | if (nanoseconds == -1) |
| 254 | return; | 254 | return; |
| 255 | _dbg_assert_(Kernel, thread != nullptr); | ||
| 256 | 255 | ||
| 257 | u64 microseconds = nanoseconds / 1000; | 256 | u64 microseconds = nanoseconds / 1000; |
| 258 | CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, thread->GetHandle()); | 257 | CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, GetHandle()); |
| 259 | } | 258 | } |
| 260 | 259 | ||
| 261 | void Thread::ReleaseWaitObject(WaitObject* wait_object) { | 260 | void Thread::ReleaseWaitObject(WaitObject* wait_object) { |
| @@ -418,7 +417,7 @@ void Thread::SetPriority(s32 priority) { | |||
| 418 | } | 417 | } |
| 419 | } | 418 | } |
| 420 | 419 | ||
| 421 | Handle SetupIdleThread() { | 420 | SharedPtr<Thread> SetupIdleThread() { |
| 422 | // We need to pass a few valid values to get around parameter checking in Thread::Create. | 421 | // We need to pass a few valid values to get around parameter checking in Thread::Create. |
| 423 | auto thread_res = Thread::Create("idle", Memory::KERNEL_MEMORY_VADDR, THREADPRIO_LOWEST, 0, | 422 | auto thread_res = Thread::Create("idle", Memory::KERNEL_MEMORY_VADDR, THREADPRIO_LOWEST, 0, |
| 424 | THREADPROCESSORID_0, 0, Kernel::DEFAULT_STACK_SIZE); | 423 | THREADPROCESSORID_0, 0, Kernel::DEFAULT_STACK_SIZE); |
| @@ -427,7 +426,7 @@ Handle SetupIdleThread() { | |||
| 427 | 426 | ||
| 428 | thread->idle = true; | 427 | thread->idle = true; |
| 429 | CallThread(thread.get()); | 428 | CallThread(thread.get()); |
| 430 | return thread->GetHandle(); | 429 | return thread; |
| 431 | } | 430 | } |
| 432 | 431 | ||
| 433 | SharedPtr<Thread> SetupMainThread(s32 priority, u32 stack_size) { | 432 | 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: | |||
| 78 | void ResumeFromWait(); | 78 | void ResumeFromWait(); |
| 79 | 79 | ||
| 80 | /** | 80 | /** |
| 81 | * Schedules an event to wake up the specified thread after the specified delay. | ||
| 82 | * @param nanoseconds The time this thread will be allowed to sleep for. | ||
| 83 | */ | ||
| 84 | void WakeAfterDelay(s64 nanoseconds); | ||
| 85 | |||
| 86 | /** | ||
| 81 | * Sets the result after the thread awakens (from either WaitSynchronization SVC) | 87 | * Sets the result after the thread awakens (from either WaitSynchronization SVC) |
| 82 | * @param result Value to set to the returned result | 88 | * @param result Value to set to the returned result |
| 83 | */ | 89 | */ |
| @@ -151,19 +157,12 @@ void WaitCurrentThread_WaitSynchronization(SharedPtr<WaitObject> wait_object, bo | |||
| 151 | void WaitCurrentThread_ArbitrateAddress(VAddr wait_address); | 157 | void WaitCurrentThread_ArbitrateAddress(VAddr wait_address); |
| 152 | 158 | ||
| 153 | /** | 159 | /** |
| 154 | * Schedules an event to wake up the specified thread after the specified delay. | ||
| 155 | * @param handle The thread handle. | ||
| 156 | * @param nanoseconds The time this thread will be allowed to sleep for. | ||
| 157 | */ | ||
| 158 | void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds); | ||
| 159 | |||
| 160 | /** | ||
| 161 | * Sets up the idle thread, this is a thread that is intended to never execute instructions, | 160 | * Sets up the idle thread, this is a thread that is intended to never execute instructions, |
| 162 | * only to advance the timing. It is scheduled when there are no other ready threads in the thread queue | 161 | * only to advance the timing. It is scheduled when there are no other ready threads in the thread queue |
| 163 | * and will try to yield on every call. | 162 | * and will try to yield on every call. |
| 164 | * @returns The handle of the idle thread | 163 | * @returns The handle of the idle thread |
| 165 | */ | 164 | */ |
| 166 | Handle SetupIdleThread(); | 165 | SharedPtr<Thread> SetupIdleThread(); |
| 167 | 166 | ||
| 168 | /// Initialize threading | 167 | /// Initialize threading |
| 169 | void ThreadingInit(); | 168 | 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) { | |||
| 152 | Kernel::WaitCurrentThread_WaitSynchronization(object, false, false); | 152 | Kernel::WaitCurrentThread_WaitSynchronization(object, false, false); |
| 153 | 153 | ||
| 154 | // Create an event to wake the thread up after the specified nanosecond delay has passed | 154 | // Create an event to wake the thread up after the specified nanosecond delay has passed |
| 155 | Kernel::WakeThreadAfterDelay(Kernel::GetCurrentThread(), nano_seconds); | 155 | Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds); |
| 156 | 156 | ||
| 157 | HLE::Reschedule(__func__); | 157 | HLE::Reschedule(__func__); |
| 158 | 158 | ||
| @@ -228,7 +228,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou | |||
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | // Create an event to wake the thread up after the specified nanosecond delay has passed | 230 | // Create an event to wake the thread up after the specified nanosecond delay has passed |
| 231 | Kernel::WakeThreadAfterDelay(Kernel::GetCurrentThread(), nano_seconds); | 231 | Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds); |
| 232 | 232 | ||
| 233 | HLE::Reschedule(__func__); | 233 | HLE::Reschedule(__func__); |
| 234 | 234 | ||
| @@ -540,7 +540,7 @@ static void SleepThread(s64 nanoseconds) { | |||
| 540 | Kernel::WaitCurrentThread_Sleep(); | 540 | Kernel::WaitCurrentThread_Sleep(); |
| 541 | 541 | ||
| 542 | // Create an event to wake the thread up after the specified nanosecond delay has passed | 542 | // Create an event to wake the thread up after the specified nanosecond delay has passed |
| 543 | Kernel::WakeThreadAfterDelay(Kernel::GetCurrentThread(), nanoseconds); | 543 | Kernel::GetCurrentThread()->WakeAfterDelay(nanoseconds); |
| 544 | 544 | ||
| 545 | HLE::Reschedule(__func__); | 545 | HLE::Reschedule(__func__); |
| 546 | } | 546 | } |