diff options
| author | 2015-01-18 13:25:51 -0500 | |
|---|---|---|
| committer | 2015-01-21 20:47:38 -0500 | |
| commit | e5a9f1c64483e01b7856c581ae5685d0c5ad88dc (patch) | |
| tree | 6ab483afc7aa00bdcff51f0d6b7015b9edd5e5bf /src/core/hle/kernel/thread.h | |
| parent | WaitSynchronizationN: Improved comments (diff) | |
| download | yuzu-e5a9f1c64483e01b7856c581ae5685d0c5ad88dc.tar.gz yuzu-e5a9f1c64483e01b7856c581ae5685d0c5ad88dc.tar.xz yuzu-e5a9f1c64483e01b7856c581ae5685d0c5ad88dc.zip | |
Kernel: Get rid of WaitTypes and simplify lots of code, removing hacks.
Diffstat (limited to 'src/core/hle/kernel/thread.h')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index dff6bbaec..cb48fcadc 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -38,18 +38,6 @@ enum ThreadStatus { | |||
| 38 | THREADSTATUS_WAITSUSPEND = THREADSTATUS_WAIT | THREADSTATUS_SUSPEND | 38 | THREADSTATUS_WAITSUSPEND = THREADSTATUS_WAIT | THREADSTATUS_SUSPEND |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | enum WaitType { | ||
| 42 | WAITTYPE_NONE, | ||
| 43 | WAITTYPE_SLEEP, | ||
| 44 | WAITTYPE_SEMA, | ||
| 45 | WAITTYPE_EVENT, | ||
| 46 | WAITTYPE_THREADEND, | ||
| 47 | WAITTYPE_MUTEX, | ||
| 48 | WAITTYPE_SYNCH, | ||
| 49 | WAITTYPE_ARB, | ||
| 50 | WAITTYPE_TIMER, | ||
| 51 | }; | ||
| 52 | |||
| 53 | namespace Kernel { | 41 | namespace Kernel { |
| 54 | 42 | ||
| 55 | class Thread : public WaitObject { | 43 | class Thread : public WaitObject { |
| @@ -70,7 +58,7 @@ public: | |||
| 70 | inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } | 58 | inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } |
| 71 | inline bool IsIdle() const { return idle; } | 59 | inline bool IsIdle() const { return idle; } |
| 72 | 60 | ||
| 73 | ResultVal<bool> Wait(bool wait_thread) override; | 61 | ResultVal<bool> Wait() override; |
| 74 | ResultVal<bool> Acquire() override; | 62 | ResultVal<bool> Acquire() override; |
| 75 | 63 | ||
| 76 | s32 GetPriority() const { return current_priority; } | 64 | s32 GetPriority() const { return current_priority; } |
| @@ -90,12 +78,6 @@ public: | |||
| 90 | void ResumeFromWait(); | 78 | void ResumeFromWait(); |
| 91 | 79 | ||
| 92 | /** | 80 | /** |
| 93 | * Sets the waiting mode of the thread | ||
| 94 | * @param wait_all If true, wait for all objects, otherwise just wait for the first one | ||
| 95 | */ | ||
| 96 | void SetWaitAll(bool wait_all) { this->wait_all = wait_all; } | ||
| 97 | |||
| 98 | /** | ||
| 99 | * Sets the output values after the thread awakens from WaitSynchronization | 81 | * Sets the output values after the thread awakens from WaitSynchronization |
| 100 | * @param return_val Value returned | 82 | * @param return_val Value returned |
| 101 | * @param out_val Value to set to the output parameter | 83 | * @param out_val Value to set to the output parameter |
| @@ -116,9 +98,10 @@ public: | |||
| 116 | 98 | ||
| 117 | s32 processor_id; | 99 | s32 processor_id; |
| 118 | 100 | ||
| 119 | WaitType wait_type; | 101 | std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on |
| 120 | std::vector<SharedPtr<WaitObject>> wait_objects; | 102 | |
| 121 | VAddr wait_address; | 103 | VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address |
| 104 | bool wait_all; ///< True if the thread is waiting on all objects before resuming | ||
| 122 | 105 | ||
| 123 | std::string name; | 106 | std::string name; |
| 124 | 107 | ||
| @@ -126,7 +109,6 @@ public: | |||
| 126 | bool idle = false; | 109 | bool idle = false; |
| 127 | 110 | ||
| 128 | private: | 111 | private: |
| 129 | bool wait_all = false; | ||
| 130 | 112 | ||
| 131 | Thread() = default; | 113 | Thread() = default; |
| 132 | }; | 114 | }; |
| @@ -146,19 +128,15 @@ void ArbitrateAllThreads(WaitObject* arbiter, u32 address); | |||
| 146 | /// Gets the current thread | 128 | /// Gets the current thread |
| 147 | Thread* GetCurrentThread(); | 129 | Thread* GetCurrentThread(); |
| 148 | 130 | ||
| 149 | /** | 131 | /// Waits the current thread |
| 150 | * Waits the current thread for the given type | 132 | void WaitCurrentThread(); |
| 151 | * @param wait_type Type of wait | ||
| 152 | */ | ||
| 153 | void WaitCurrentThread(WaitType wait_type); | ||
| 154 | 133 | ||
| 155 | /** | 134 | /** |
| 156 | * Waits the current thread from a WaitSynchronization call | 135 | * Waits the current thread from a WaitSynchronization call |
| 157 | * @param wait_type Type of wait | ||
| 158 | * @param wait_object Kernel object that we are waiting on | 136 | * @param wait_object Kernel object that we are waiting on |
| 159 | * @param index Index of calling object (for WaitSynchronizationN only) | 137 | * @param wait_all If true, wait on all objects before resuming (for WaitSynchronizationN only) |
| 160 | */ | 138 | */ |
| 161 | void WaitCurrentThread_WaitSynchronization(WaitType wait_type, WaitObject* wait_object, unsigned index=0); | 139 | void WaitCurrentThread_WaitSynchronization(WaitObject* wait_object, bool wait_all=false); |
| 162 | 140 | ||
| 163 | /** | 141 | /** |
| 164 | * Waits the current thread from an ArbitrateAddress call | 142 | * Waits the current thread from an ArbitrateAddress call |
| @@ -181,6 +159,7 @@ void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds); | |||
| 181 | * @returns The handle of the idle thread | 159 | * @returns The handle of the idle thread |
| 182 | */ | 160 | */ |
| 183 | Handle SetupIdleThread(); | 161 | Handle SetupIdleThread(); |
| 162 | |||
| 184 | /// Initialize threading | 163 | /// Initialize threading |
| 185 | void ThreadingInit(); | 164 | void ThreadingInit(); |
| 186 | 165 | ||