diff options
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 60 |
1 files changed, 9 insertions, 51 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 3e9ea464d..ef63c5f41 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -22,60 +22,18 @@ | |||
| 22 | 22 | ||
| 23 | namespace Kernel { | 23 | namespace Kernel { |
| 24 | 24 | ||
| 25 | class Thread : public Kernel::Object { | 25 | ResultVal<bool> Thread::WaitSynchronization() { |
| 26 | public: | 26 | const bool wait = status != THREADSTATUS_DORMANT; |
| 27 | 27 | if (wait) { | |
| 28 | std::string GetName() const override { return name; } | 28 | Handle thread = GetCurrentThreadHandle(); |
| 29 | std::string GetTypeName() const override { return "Thread"; } | 29 | if (std::find(waiting_threads.begin(), waiting_threads.end(), thread) == waiting_threads.end()) { |
| 30 | 30 | waiting_threads.push_back(thread); | |
| 31 | static const HandleType HANDLE_TYPE = HandleType::Thread; | ||
| 32 | HandleType GetHandleType() const override { return HANDLE_TYPE; } | ||
| 33 | |||
| 34 | inline bool IsRunning() const { return (status & THREADSTATUS_RUNNING) != 0; } | ||
| 35 | inline bool IsStopped() const { return (status & THREADSTATUS_DORMANT) != 0; } | ||
| 36 | inline bool IsReady() const { return (status & THREADSTATUS_READY) != 0; } | ||
| 37 | inline bool IsWaiting() const { return (status & THREADSTATUS_WAIT) != 0; } | ||
| 38 | inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } | ||
| 39 | inline bool IsIdle() const { return idle; } | ||
| 40 | |||
| 41 | ResultVal<bool> WaitSynchronization() override { | ||
| 42 | const bool wait = status != THREADSTATUS_DORMANT; | ||
| 43 | if (wait) { | ||
| 44 | Handle thread = GetCurrentThreadHandle(); | ||
| 45 | if (std::find(waiting_threads.begin(), waiting_threads.end(), thread) == waiting_threads.end()) { | ||
| 46 | waiting_threads.push_back(thread); | ||
| 47 | } | ||
| 48 | WaitCurrentThread(WAITTYPE_THREADEND, this->GetHandle()); | ||
| 49 | } | 31 | } |
| 50 | 32 | WaitCurrentThread(WAITTYPE_THREADEND, this->GetHandle()); | |
| 51 | return MakeResult<bool>(wait); | ||
| 52 | } | 33 | } |
| 53 | 34 | ||
| 54 | Core::ThreadContext context; | 35 | return MakeResult<bool>(wait); |
| 55 | 36 | } | |
| 56 | u32 thread_id; | ||
| 57 | |||
| 58 | u32 status; | ||
| 59 | u32 entry_point; | ||
| 60 | u32 stack_top; | ||
| 61 | u32 stack_size; | ||
| 62 | |||
| 63 | s32 initial_priority; | ||
| 64 | s32 current_priority; | ||
| 65 | |||
| 66 | s32 processor_id; | ||
| 67 | |||
| 68 | WaitType wait_type; | ||
| 69 | Handle wait_handle; | ||
| 70 | VAddr wait_address; | ||
| 71 | |||
| 72 | std::vector<Handle> waiting_threads; | ||
| 73 | |||
| 74 | std::string name; | ||
| 75 | |||
| 76 | /// Whether this thread is intended to never actually be executed, i.e. always idle | ||
| 77 | bool idle = false; | ||
| 78 | }; | ||
| 79 | 37 | ||
| 80 | // Lists all thread ids that aren't deleted/etc. | 38 | // Lists all thread ids that aren't deleted/etc. |
| 81 | static std::vector<Handle> thread_queue; | 39 | static std::vector<Handle> thread_queue; |