summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2015-02-02 19:04:04 +0100
committerbunnei <bunneidev@gmail.com>2015-02-02 19:04:04 +0100
commit7f730ed158bc9bba064100b9644b318134ef0bb3 (patch)
treec4181a69ff882e1af1b7d65bf3596a6cb3dd88b9 /src/core/hle/kernel/thread.h
parentMerge pull request #517 from bunnei/blend-factors (diff)
parentKernel: Stop creating useless Handles during object creation (diff)
downloadyuzu-7f730ed158bc9bba064100b9644b318134ef0bb3.tar
yuzu-7f730ed158bc9bba064100b9644b318134ef0bb3.tar.gz
yuzu-7f730ed158bc9bba064100b9644b318134ef0bb3.tar.bz2
yuzu-7f730ed158bc9bba064100b9644b318134ef0bb3.tar.lz
yuzu-7f730ed158bc9bba064100b9644b318134ef0bb3.tar.xz
yuzu-7f730ed158bc9bba064100b9644b318134ef0bb3.tar.zst
yuzu-7f730ed158bc9bba064100b9644b318134ef0bb3.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/thread.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index d6299364a..633bb7c98 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -7,6 +7,8 @@
#include <string>
#include <vector>
+#include <boost/container/flat_set.hpp>
+
#include "common/common_types.h"
#include "core/core.h"
@@ -40,6 +42,8 @@ enum ThreadStatus {
namespace Kernel {
+class Mutex;
+
class Thread final : public WaitObject {
public:
static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, s32 priority,
@@ -78,6 +82,12 @@ public:
void ResumeFromWait();
/**
+ * Schedules an event to wake up the specified thread after the specified delay.
+ * @param nanoseconds The time this thread will be allowed to sleep for.
+ */
+ void WakeAfterDelay(s64 nanoseconds);
+
+ /**
* Sets the result after the thread awakens (from either WaitSynchronization SVC)
* @param result Value to set to the returned result
*/
@@ -103,8 +113,10 @@ public:
s32 processor_id;
- std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on
+ /// Mutexes currently held by this thread, which will be released when it exits.
+ boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
+ std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on
VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
bool wait_all; ///< True if the thread is waiting on all objects before resuming
bool wait_set_output; ///< True if the output parameter should be set on thread wakeup
@@ -115,9 +127,15 @@ public:
bool idle = false;
private:
- Thread() = default;
+ Thread();
+ ~Thread() override;
+
+ /// Handle used as userdata to reference this object when inserting into the CoreTiming queue.
+ Handle callback_handle;
};
+extern SharedPtr<Thread> g_main_thread;
+
/// Sets up the primary application thread
SharedPtr<Thread> SetupMainThread(s32 priority, u32 stack_size);
@@ -151,19 +169,12 @@ void WaitCurrentThread_WaitSynchronization(SharedPtr<WaitObject> wait_object, bo
void WaitCurrentThread_ArbitrateAddress(VAddr wait_address);
/**
- * Schedules an event to wake up the specified thread after the specified delay.
- * @param handle The thread handle.
- * @param nanoseconds The time this thread will be allowed to sleep for.
- */
-void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds);
-
-/**
* Sets up the idle thread, this is a thread that is intended to never execute instructions,
* only to advance the timing. It is scheduled when there are no other ready threads in the thread queue
* and will try to yield on every call.
* @returns The handle of the idle thread
*/
-Handle SetupIdleThread();
+SharedPtr<Thread> SetupIdleThread();
/// Initialize threading
void ThreadingInit();