diff options
| author | 2014-12-22 04:32:03 -0200 | |
|---|---|---|
| committer | 2015-01-09 03:51:55 -0200 | |
| commit | ba72208cd4905410eab8b996da0fa05fd05c72ff (patch) | |
| tree | 3dcaf53894232e83741d3a524c7c53b8da60409c /src/core/hle/kernel/thread.h | |
| parent | Move ThreadContext to core/core.h and deal with the fallout (diff) | |
| download | yuzu-ba72208cd4905410eab8b996da0fa05fd05c72ff.tar.gz yuzu-ba72208cd4905410eab8b996da0fa05fd05c72ff.tar.xz yuzu-ba72208cd4905410eab8b996da0fa05fd05c72ff.zip | |
Kernel: Move Thread's definition to the header file
Diffstat (limited to 'src/core/hle/kernel/thread.h')
| -rw-r--r-- | src/core/hle/kernel/thread.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 58bd85ac6..51290975e 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -4,8 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <string> | ||
| 8 | #include <vector> | ||
| 9 | |||
| 7 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 8 | 11 | ||
| 12 | #include "core/core.h" | ||
| 9 | #include "core/mem_map.h" | 13 | #include "core/mem_map.h" |
| 10 | 14 | ||
| 11 | #include "core/hle/kernel/kernel.h" | 15 | #include "core/hle/kernel/kernel.h" |
| @@ -48,6 +52,56 @@ enum WaitType { | |||
| 48 | 52 | ||
| 49 | namespace Kernel { | 53 | namespace Kernel { |
| 50 | 54 | ||
| 55 | class Thread : public Kernel::Object { | ||
| 56 | public: | ||
| 57 | std::string GetName() const override { return name; } | ||
| 58 | std::string GetTypeName() const override { return "Thread"; } | ||
| 59 | |||
| 60 | static const HandleType HANDLE_TYPE = HandleType::Thread; | ||
| 61 | HandleType GetHandleType() const override { return HANDLE_TYPE; } | ||
| 62 | |||
| 63 | inline bool IsRunning() const { return (status & THREADSTATUS_RUNNING) != 0; } | ||
| 64 | inline bool IsStopped() const { return (status & THREADSTATUS_DORMANT) != 0; } | ||
| 65 | inline bool IsReady() const { return (status & THREADSTATUS_READY) != 0; } | ||
| 66 | inline bool IsWaiting() const { return (status & THREADSTATUS_WAIT) != 0; } | ||
| 67 | inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } | ||
| 68 | inline bool IsIdle() const { return idle; } | ||
| 69 | |||
| 70 | ResultVal<bool> WaitSynchronization() override; | ||
| 71 | |||
| 72 | Core::ThreadContext context; | ||
| 73 | |||
| 74 | u32 thread_id; | ||
| 75 | |||
| 76 | u32 status; | ||
| 77 | u32 entry_point; | ||
| 78 | u32 stack_top; | ||
| 79 | u32 stack_size; | ||
| 80 | |||
| 81 | s32 initial_priority; | ||
| 82 | s32 current_priority; | ||
| 83 | |||
| 84 | s32 processor_id; | ||
| 85 | |||
| 86 | WaitType wait_type; | ||
| 87 | Handle wait_handle; | ||
| 88 | VAddr wait_address; | ||
| 89 | |||
| 90 | std::vector<Handle> waiting_threads; | ||
| 91 | |||
| 92 | std::string name; | ||
| 93 | |||
| 94 | /// Whether this thread is intended to never actually be executed, i.e. always idle | ||
| 95 | bool idle = false; | ||
| 96 | |||
| 97 | private: | ||
| 98 | // TODO(yuriks) Temporary until the creation logic can be moved into a static function | ||
| 99 | friend Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 priority, | ||
| 100 | s32 processor_id, u32 stack_top, int stack_size); | ||
| 101 | |||
| 102 | Thread() = default; | ||
| 103 | }; | ||
| 104 | |||
| 51 | /// Creates a new thread - wrapper for external user | 105 | /// Creates a new thread - wrapper for external user |
| 52 | Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s32 processor_id, | 106 | Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s32 processor_id, |
| 53 | u32 stack_top, int stack_size=Kernel::DEFAULT_STACK_SIZE); | 107 | u32 stack_top, int stack_size=Kernel::DEFAULT_STACK_SIZE); |
| @@ -78,6 +132,9 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address); | |||
| 78 | /// Arbitrate all threads currently waiting... | 132 | /// Arbitrate all threads currently waiting... |
| 79 | void ArbitrateAllThreads(u32 arbiter, u32 address); | 133 | void ArbitrateAllThreads(u32 arbiter, u32 address); |
| 80 | 134 | ||
| 135 | /// Gets the current thread | ||
| 136 | Thread* GetCurrentThread(); | ||
| 137 | |||
| 81 | /// Gets the current thread handle | 138 | /// Gets the current thread handle |
| 82 | Handle GetCurrentThreadHandle(); | 139 | Handle GetCurrentThreadHandle(); |
| 83 | 140 | ||