summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-10-05 13:41:54 -0400
committerGravatar GitHub2018-10-05 13:41:54 -0400
commite51d715700a35a8f14e5b804b6f7553c9a40888b (patch)
tree96917effcab47b089718a90851b2b203717d324a /src/core/hle/kernel/thread.cpp
parentMerge pull request #1442 from lioncash/format (diff)
parentkernel/thread: Make all instance variables private (diff)
downloadyuzu-e51d715700a35a8f14e5b804b6f7553c9a40888b.tar.gz
yuzu-e51d715700a35a8f14e5b804b6f7553c9a40888b.tar.xz
yuzu-e51d715700a35a8f14e5b804b6f7553c9a40888b.zip
Merge pull request #1439 from lioncash/thread
kernel/thread: Make all instance variables private
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index b5c16cfbb..354043c53 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -70,7 +70,7 @@ void Thread::Stop() {
70 70
71void WaitCurrentThread_Sleep() { 71void WaitCurrentThread_Sleep() {
72 Thread* thread = GetCurrentThread(); 72 Thread* thread = GetCurrentThread();
73 thread->status = ThreadStatus::WaitSleep; 73 thread->SetStatus(ThreadStatus::WaitSleep);
74} 74}
75 75
76void ExitCurrentThread() { 76void ExitCurrentThread() {
@@ -269,9 +269,9 @@ SharedPtr<Thread> SetupMainThread(KernelCore& kernel, VAddr entry_point, u32 pri
269 SharedPtr<Thread> thread = std::move(thread_res).Unwrap(); 269 SharedPtr<Thread> thread = std::move(thread_res).Unwrap();
270 270
271 // Register 1 must be a handle to the main thread 271 // Register 1 must be a handle to the main thread
272 thread->guest_handle = kernel.HandleTable().Create(thread).Unwrap(); 272 const Handle guest_handle = kernel.HandleTable().Create(thread).Unwrap();
273 273 thread->SetGuestHandle(guest_handle);
274 thread->context.cpu_registers[1] = thread->guest_handle; 274 thread->GetContext().cpu_registers[1] = guest_handle;
275 275
276 // Threads by default are dormant, wake up the main thread so it runs when the scheduler fires 276 // Threads by default are dormant, wake up the main thread so it runs when the scheduler fires
277 thread->ResumeFromWait(); 277 thread->ResumeFromWait();
@@ -299,6 +299,18 @@ VAddr Thread::GetCommandBufferAddress() const {
299 return GetTLSAddress() + CommandHeaderOffset; 299 return GetTLSAddress() + CommandHeaderOffset;
300} 300}
301 301
302void Thread::SetStatus(ThreadStatus new_status) {
303 if (new_status == status) {
304 return;
305 }
306
307 if (status == ThreadStatus::Running) {
308 last_running_ticks = CoreTiming::GetTicks();
309 }
310
311 status = new_status;
312}
313
302void Thread::AddMutexWaiter(SharedPtr<Thread> thread) { 314void Thread::AddMutexWaiter(SharedPtr<Thread> thread) {
303 if (thread->lock_owner == this) { 315 if (thread->lock_owner == this) {
304 // If the thread is already waiting for this thread to release the mutex, ensure that the 316 // If the thread is already waiting for this thread to release the mutex, ensure that the
@@ -393,6 +405,18 @@ void Thread::ChangeCore(u32 core, u64 mask) {
393 Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); 405 Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule();
394} 406}
395 407
408bool Thread::AllWaitObjectsReady() {
409 return std::none_of(
410 wait_objects.begin(), wait_objects.end(),
411 [this](const SharedPtr<WaitObject>& object) { return object->ShouldWait(this); });
412}
413
414bool Thread::InvokeWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> thread,
415 SharedPtr<WaitObject> object, std::size_t index) {
416 ASSERT(wakeup_callback);
417 return wakeup_callback(reason, std::move(thread), std::move(object), index);
418}
419
396//////////////////////////////////////////////////////////////////////////////////////////////////// 420////////////////////////////////////////////////////////////////////////////////////////////////////
397 421
398/** 422/**