diff options
| author | 2020-02-14 14:40:20 -0500 | |
|---|---|---|
| committer | 2020-02-14 14:40:20 -0500 | |
| commit | f552d553bac1374c583d748dad27f8c86e86c4a0 (patch) | |
| tree | 1da4aa037ff417fa4fd43bffac267dcb2b55a72d /src/core/hle/kernel/thread.h | |
| parent | Merge pull request #3379 from ReinUsesLisp/cbuf-offset (diff) | |
| parent | Core: Correct compilition in GCC (diff) | |
| download | yuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.tar.gz yuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.tar.xz yuzu-f552d553bac1374c583d748dad27f8c86e86c4a0.zip | |
Merge pull request #3401 from FernandoS27/synchronization
Set of refactors for Kernel Synchronization and Hardware Constants
Diffstat (limited to 'src/core/hle/kernel/thread.h')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 3bcf9e137..7a4916318 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "core/arm/arm_interface.h" | 12 | #include "core/arm/arm_interface.h" |
| 13 | #include "core/hle/kernel/object.h" | 13 | #include "core/hle/kernel/object.h" |
| 14 | #include "core/hle/kernel/wait_object.h" | 14 | #include "core/hle/kernel/synchronization_object.h" |
| 15 | #include "core/hle/result.h" | 15 | #include "core/hle/result.h" |
| 16 | 16 | ||
| 17 | namespace Kernel { | 17 | namespace Kernel { |
| @@ -95,7 +95,7 @@ enum class ThreadSchedMasks : u32 { | |||
| 95 | ForcePauseMask = 0x0070, | 95 | ForcePauseMask = 0x0070, |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | class Thread final : public WaitObject { | 98 | class Thread final : public SynchronizationObject { |
| 99 | public: | 99 | public: |
| 100 | explicit Thread(KernelCore& kernel); | 100 | explicit Thread(KernelCore& kernel); |
| 101 | ~Thread() override; | 101 | ~Thread() override; |
| @@ -104,11 +104,11 @@ public: | |||
| 104 | 104 | ||
| 105 | using ThreadContext = Core::ARM_Interface::ThreadContext; | 105 | using ThreadContext = Core::ARM_Interface::ThreadContext; |
| 106 | 106 | ||
| 107 | using ThreadWaitObjects = std::vector<std::shared_ptr<WaitObject>>; | 107 | using ThreadSynchronizationObjects = std::vector<std::shared_ptr<SynchronizationObject>>; |
| 108 | 108 | ||
| 109 | using WakeupCallback = | 109 | using WakeupCallback = |
| 110 | std::function<bool(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, | 110 | std::function<bool(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, |
| 111 | std::shared_ptr<WaitObject> object, std::size_t index)>; | 111 | std::shared_ptr<SynchronizationObject> object, std::size_t index)>; |
| 112 | 112 | ||
| 113 | /** | 113 | /** |
| 114 | * Creates and returns a new thread. The new thread is immediately scheduled | 114 | * Creates and returns a new thread. The new thread is immediately scheduled |
| @@ -146,6 +146,7 @@ public: | |||
| 146 | 146 | ||
| 147 | bool ShouldWait(const Thread* thread) const override; | 147 | bool ShouldWait(const Thread* thread) const override; |
| 148 | void Acquire(Thread* thread) override; | 148 | void Acquire(Thread* thread) override; |
| 149 | bool IsSignaled() const override; | ||
| 149 | 150 | ||
| 150 | /** | 151 | /** |
| 151 | * Gets the thread's current priority | 152 | * Gets the thread's current priority |
| @@ -233,7 +234,7 @@ public: | |||
| 233 | * | 234 | * |
| 234 | * @param object Object to query the index of. | 235 | * @param object Object to query the index of. |
| 235 | */ | 236 | */ |
| 236 | s32 GetWaitObjectIndex(std::shared_ptr<WaitObject> object) const; | 237 | s32 GetSynchronizationObjectIndex(std::shared_ptr<SynchronizationObject> object) const; |
| 237 | 238 | ||
| 238 | /** | 239 | /** |
| 239 | * Stops a thread, invalidating it from further use | 240 | * Stops a thread, invalidating it from further use |
| @@ -314,15 +315,15 @@ public: | |||
| 314 | return owner_process; | 315 | return owner_process; |
| 315 | } | 316 | } |
| 316 | 317 | ||
| 317 | const ThreadWaitObjects& GetWaitObjects() const { | 318 | const ThreadSynchronizationObjects& GetSynchronizationObjects() const { |
| 318 | return wait_objects; | 319 | return wait_objects; |
| 319 | } | 320 | } |
| 320 | 321 | ||
| 321 | void SetWaitObjects(ThreadWaitObjects objects) { | 322 | void SetSynchronizationObjects(ThreadSynchronizationObjects objects) { |
| 322 | wait_objects = std::move(objects); | 323 | wait_objects = std::move(objects); |
| 323 | } | 324 | } |
| 324 | 325 | ||
| 325 | void ClearWaitObjects() { | 326 | void ClearSynchronizationObjects() { |
| 326 | for (const auto& waiting_object : wait_objects) { | 327 | for (const auto& waiting_object : wait_objects) { |
| 327 | waiting_object->RemoveWaitingThread(SharedFrom(this)); | 328 | waiting_object->RemoveWaitingThread(SharedFrom(this)); |
| 328 | } | 329 | } |
| @@ -330,7 +331,7 @@ public: | |||
| 330 | } | 331 | } |
| 331 | 332 | ||
| 332 | /// Determines whether all the objects this thread is waiting on are ready. | 333 | /// Determines whether all the objects this thread is waiting on are ready. |
| 333 | bool AllWaitObjectsReady() const; | 334 | bool AllSynchronizationObjectsReady() const; |
| 334 | 335 | ||
| 335 | const MutexWaitingThreads& GetMutexWaitingThreads() const { | 336 | const MutexWaitingThreads& GetMutexWaitingThreads() const { |
| 336 | return wait_mutex_threads; | 337 | return wait_mutex_threads; |
| @@ -395,7 +396,7 @@ public: | |||
| 395 | * will cause an assertion to trigger. | 396 | * will cause an assertion to trigger. |
| 396 | */ | 397 | */ |
| 397 | bool InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, | 398 | bool InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, |
| 398 | std::shared_ptr<WaitObject> object, std::size_t index); | 399 | std::shared_ptr<SynchronizationObject> object, std::size_t index); |
| 399 | 400 | ||
| 400 | u32 GetIdealCore() const { | 401 | u32 GetIdealCore() const { |
| 401 | return ideal_core; | 402 | return ideal_core; |
| @@ -494,7 +495,7 @@ private: | |||
| 494 | 495 | ||
| 495 | /// Objects that the thread is waiting on, in the same order as they were | 496 | /// Objects that the thread is waiting on, in the same order as they were |
| 496 | /// passed to WaitSynchronization. | 497 | /// passed to WaitSynchronization. |
| 497 | ThreadWaitObjects wait_objects; | 498 | ThreadSynchronizationObjects wait_objects; |
| 498 | 499 | ||
| 499 | /// List of threads that are waiting for a mutex that is held by this thread. | 500 | /// List of threads that are waiting for a mutex that is held by this thread. |
| 500 | MutexWaitingThreads wait_mutex_threads; | 501 | MutexWaitingThreads wait_mutex_threads; |