|
|
|
@ -129,6 +129,7 @@ public: |
|
|
|
using WakeupCallback = |
|
|
|
std::function<bool(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, |
|
|
|
std::shared_ptr<SynchronizationObject> object, std::size_t index)>; |
|
|
|
using HLECallback = std::function<bool(std::shared_ptr<Thread> thread)>; |
|
|
|
|
|
|
|
/** |
|
|
|
* Creates and returns a new thread. The new thread is immediately scheduled |
|
|
|
@ -142,10 +143,10 @@ public: |
|
|
|
* @param owner_process The parent process for the thread, if null, it's a kernel thread |
|
|
|
* @return A shared pointer to the newly created thread |
|
|
|
*/ |
|
|
|
static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags, std::string name, |
|
|
|
VAddr entry_point, u32 priority, u64 arg, |
|
|
|
s32 processor_id, VAddr stack_top, |
|
|
|
Process* owner_process); |
|
|
|
static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags, |
|
|
|
std::string name, VAddr entry_point, |
|
|
|
u32 priority, u64 arg, s32 processor_id, |
|
|
|
VAddr stack_top, Process* owner_process); |
|
|
|
|
|
|
|
/** |
|
|
|
* Creates and returns a new thread. The new thread is immediately scheduled |
|
|
|
@ -161,10 +162,10 @@ public: |
|
|
|
* @param thread_start_parameter The parameter which will passed to host context on init |
|
|
|
* @return A shared pointer to the newly created thread |
|
|
|
*/ |
|
|
|
static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags, std::string name, |
|
|
|
VAddr entry_point, u32 priority, u64 arg, |
|
|
|
s32 processor_id, VAddr stack_top, |
|
|
|
Process* owner_process, |
|
|
|
static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags, |
|
|
|
std::string name, VAddr entry_point, |
|
|
|
u32 priority, u64 arg, s32 processor_id, |
|
|
|
VAddr stack_top, Process* owner_process, |
|
|
|
std::function<void(void*)>&& thread_start_func, |
|
|
|
void* thread_start_parameter); |
|
|
|
|
|
|
|
@ -447,17 +448,37 @@ public: |
|
|
|
} |
|
|
|
|
|
|
|
bool HasWakeupCallback() const { |
|
|
|
return wakeup_callback != nullptr; |
|
|
|
return hle_callback != nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
bool HasHLECallback() const { |
|
|
|
return hle_callback != nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
void SetWakeupCallback(WakeupCallback callback) { |
|
|
|
wakeup_callback = std::move(callback); |
|
|
|
hle_callback = std::move(callback); |
|
|
|
} |
|
|
|
|
|
|
|
void SetHLECallback(WakeupCallback callback) { |
|
|
|
hle_callback = std::move(callback); |
|
|
|
} |
|
|
|
|
|
|
|
void SetHLETimeEvent(Handle time_event) { |
|
|
|
hle_time_event = time_event; |
|
|
|
} |
|
|
|
|
|
|
|
Handle GetHLETimeEvent() const { |
|
|
|
return hle_time_event; |
|
|
|
} |
|
|
|
|
|
|
|
void InvalidateWakeupCallback() { |
|
|
|
SetWakeupCallback(nullptr); |
|
|
|
} |
|
|
|
|
|
|
|
void InvalidateHLECallback() { |
|
|
|
SetHLECallback(nullptr); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Invokes the thread's wakeup callback. |
|
|
|
* |
|
|
|
@ -466,6 +487,8 @@ public: |
|
|
|
*/ |
|
|
|
bool InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, |
|
|
|
std::shared_ptr<SynchronizationObject> object, std::size_t index); |
|
|
|
bool InvokeHLECallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, |
|
|
|
std::shared_ptr<SynchronizationObject> object, std::size_t index); |
|
|
|
|
|
|
|
u32 GetIdealCore() const { |
|
|
|
return ideal_core; |
|
|
|
@ -600,7 +623,8 @@ private: |
|
|
|
/// Callback that will be invoked when the thread is resumed from a waiting state. If the thread |
|
|
|
/// was waiting via WaitSynchronization then the object will be the last object that became |
|
|
|
/// available. In case of a timeout, the object will be nullptr. |
|
|
|
WakeupCallback wakeup_callback; |
|
|
|
WakeupCallback hle_callback; |
|
|
|
Handle hle_time_event; |
|
|
|
|
|
|
|
Scheduler* scheduler = nullptr; |
|
|
|
|
|
|
|
|