diff options
| author | 2019-11-24 20:15:51 -0500 | |
|---|---|---|
| committer | 2019-11-24 20:15:51 -0500 | |
| commit | 9046d4a5485452802b756869b7d27056ba9ea9d7 (patch) | |
| tree | 2d704d912e9054fb232b73ad69f1bc3966ed97a5 /src/core/hle/kernel/thread.h | |
| parent | Merge pull request #3098 from ReinUsesLisp/shader-invalidations (diff) | |
| download | yuzu-9046d4a5485452802b756869b7d27056ba9ea9d7.tar.gz yuzu-9046d4a5485452802b756869b7d27056ba9ea9d7.tar.xz yuzu-9046d4a5485452802b756869b7d27056ba9ea9d7.zip | |
kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects. (#3154)
* kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects.
- See https://github.com/citra-emu/citra/pull/4710 for details.
Diffstat (limited to 'src/core/hle/kernel/thread.h')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 25a6ed234..3bcf9e137 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -97,14 +97,18 @@ enum class ThreadSchedMasks : u32 { | |||
| 97 | 97 | ||
| 98 | class Thread final : public WaitObject { | 98 | class Thread final : public WaitObject { |
| 99 | public: | 99 | public: |
| 100 | using MutexWaitingThreads = std::vector<SharedPtr<Thread>>; | 100 | explicit Thread(KernelCore& kernel); |
| 101 | ~Thread() override; | ||
| 102 | |||
| 103 | using MutexWaitingThreads = std::vector<std::shared_ptr<Thread>>; | ||
| 101 | 104 | ||
| 102 | using ThreadContext = Core::ARM_Interface::ThreadContext; | 105 | using ThreadContext = Core::ARM_Interface::ThreadContext; |
| 103 | 106 | ||
| 104 | using ThreadWaitObjects = std::vector<SharedPtr<WaitObject>>; | 107 | using ThreadWaitObjects = std::vector<std::shared_ptr<WaitObject>>; |
| 105 | 108 | ||
| 106 | using WakeupCallback = std::function<bool(ThreadWakeupReason reason, SharedPtr<Thread> thread, | 109 | using WakeupCallback = |
| 107 | SharedPtr<WaitObject> object, std::size_t index)>; | 110 | std::function<bool(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, |
| 111 | std::shared_ptr<WaitObject> object, std::size_t index)>; | ||
| 108 | 112 | ||
| 109 | /** | 113 | /** |
| 110 | * 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 |
| @@ -118,10 +122,10 @@ public: | |||
| 118 | * @param owner_process The parent process for the thread | 122 | * @param owner_process The parent process for the thread |
| 119 | * @return A shared pointer to the newly created thread | 123 | * @return A shared pointer to the newly created thread |
| 120 | */ | 124 | */ |
| 121 | static ResultVal<SharedPtr<Thread>> Create(KernelCore& kernel, std::string name, | 125 | static ResultVal<std::shared_ptr<Thread>> Create(KernelCore& kernel, std::string name, |
| 122 | VAddr entry_point, u32 priority, u64 arg, | 126 | VAddr entry_point, u32 priority, u64 arg, |
| 123 | s32 processor_id, VAddr stack_top, | 127 | s32 processor_id, VAddr stack_top, |
| 124 | Process& owner_process); | 128 | Process& owner_process); |
| 125 | 129 | ||
| 126 | std::string GetName() const override { | 130 | std::string GetName() const override { |
| 127 | return name; | 131 | return name; |
| @@ -166,10 +170,10 @@ public: | |||
| 166 | void SetPriority(u32 priority); | 170 | void SetPriority(u32 priority); |
| 167 | 171 | ||
| 168 | /// Adds a thread to the list of threads that are waiting for a lock held by this thread. | 172 | /// Adds a thread to the list of threads that are waiting for a lock held by this thread. |
| 169 | void AddMutexWaiter(SharedPtr<Thread> thread); | 173 | void AddMutexWaiter(std::shared_ptr<Thread> thread); |
| 170 | 174 | ||
| 171 | /// Removes a thread from the list of threads that are waiting for a lock held by this thread. | 175 | /// Removes a thread from the list of threads that are waiting for a lock held by this thread. |
| 172 | void RemoveMutexWaiter(SharedPtr<Thread> thread); | 176 | void RemoveMutexWaiter(std::shared_ptr<Thread> thread); |
| 173 | 177 | ||
| 174 | /// Recalculates the current priority taking into account priority inheritance. | 178 | /// Recalculates the current priority taking into account priority inheritance. |
| 175 | void UpdatePriority(); | 179 | void UpdatePriority(); |
| @@ -229,7 +233,7 @@ public: | |||
| 229 | * | 233 | * |
| 230 | * @param object Object to query the index of. | 234 | * @param object Object to query the index of. |
| 231 | */ | 235 | */ |
| 232 | s32 GetWaitObjectIndex(const WaitObject* object) const; | 236 | s32 GetWaitObjectIndex(std::shared_ptr<WaitObject> object) const; |
| 233 | 237 | ||
| 234 | /** | 238 | /** |
| 235 | * Stops a thread, invalidating it from further use | 239 | * Stops a thread, invalidating it from further use |
| @@ -320,7 +324,7 @@ public: | |||
| 320 | 324 | ||
| 321 | void ClearWaitObjects() { | 325 | void ClearWaitObjects() { |
| 322 | for (const auto& waiting_object : wait_objects) { | 326 | for (const auto& waiting_object : wait_objects) { |
| 323 | waiting_object->RemoveWaitingThread(this); | 327 | waiting_object->RemoveWaitingThread(SharedFrom(this)); |
| 324 | } | 328 | } |
| 325 | wait_objects.clear(); | 329 | wait_objects.clear(); |
| 326 | } | 330 | } |
| @@ -336,7 +340,7 @@ public: | |||
| 336 | return lock_owner.get(); | 340 | return lock_owner.get(); |
| 337 | } | 341 | } |
| 338 | 342 | ||
| 339 | void SetLockOwner(SharedPtr<Thread> owner) { | 343 | void SetLockOwner(std::shared_ptr<Thread> owner) { |
| 340 | lock_owner = std::move(owner); | 344 | lock_owner = std::move(owner); |
| 341 | } | 345 | } |
| 342 | 346 | ||
| @@ -390,8 +394,8 @@ public: | |||
| 390 | * @pre A valid wakeup callback has been set. Violating this precondition | 394 | * @pre A valid wakeup callback has been set. Violating this precondition |
| 391 | * will cause an assertion to trigger. | 395 | * will cause an assertion to trigger. |
| 392 | */ | 396 | */ |
| 393 | bool InvokeWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> thread, | 397 | bool InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, |
| 394 | SharedPtr<WaitObject> object, std::size_t index); | 398 | std::shared_ptr<WaitObject> object, std::size_t index); |
| 395 | 399 | ||
| 396 | u32 GetIdealCore() const { | 400 | u32 GetIdealCore() const { |
| 397 | return ideal_core; | 401 | return ideal_core; |
| @@ -449,9 +453,6 @@ public: | |||
| 449 | } | 453 | } |
| 450 | 454 | ||
| 451 | private: | 455 | private: |
| 452 | explicit Thread(KernelCore& kernel); | ||
| 453 | ~Thread() override; | ||
| 454 | |||
| 455 | void SetSchedulingStatus(ThreadSchedStatus new_status); | 456 | void SetSchedulingStatus(ThreadSchedStatus new_status); |
| 456 | void SetCurrentPriority(u32 new_priority); | 457 | void SetCurrentPriority(u32 new_priority); |
| 457 | ResultCode SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask); | 458 | ResultCode SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask); |
| @@ -499,7 +500,7 @@ private: | |||
| 499 | MutexWaitingThreads wait_mutex_threads; | 500 | MutexWaitingThreads wait_mutex_threads; |
| 500 | 501 | ||
| 501 | /// Thread that owns the lock that this thread is waiting for. | 502 | /// Thread that owns the lock that this thread is waiting for. |
| 502 | SharedPtr<Thread> lock_owner; | 503 | std::shared_ptr<Thread> lock_owner; |
| 503 | 504 | ||
| 504 | /// If waiting on a ConditionVariable, this is the ConditionVariable address | 505 | /// If waiting on a ConditionVariable, this is the ConditionVariable address |
| 505 | VAddr condvar_wait_address = 0; | 506 | VAddr condvar_wait_address = 0; |