summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2016-12-17 12:08:38 +0100
committerwwylele <wwylele@gmail.com>2016-12-17 18:23:52 +0100
commit5728e42634740463ba2da4758d817ad09a84dc60 (patch)
tree61df2f8ed57ff935c1ac018a64f86d683df45c1e /src/core/hle/kernel
parentMerge pull request #2335 from yuriks/shader-refactor (diff)
downloadyuzu-5728e42634740463ba2da4758d817ad09a84dc60.tar
yuzu-5728e42634740463ba2da4758d817ad09a84dc60.tar.gz
yuzu-5728e42634740463ba2da4758d817ad09a84dc60.tar.bz2
yuzu-5728e42634740463ba2da4758d817ad09a84dc60.tar.lz
yuzu-5728e42634740463ba2da4758d817ad09a84dc60.tar.xz
yuzu-5728e42634740463ba2da4758d817ad09a84dc60.tar.zst
yuzu-5728e42634740463ba2da4758d817ad09a84dc60.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/thread.cpp11
-rw-r--r--src/core/hle/kernel/thread.h5
2 files changed, 14 insertions, 2 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 4bbc08516..18b696f72 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -46,7 +46,7 @@ static std::vector<SharedPtr<Thread>> thread_list;
// Lists only ready thread ids.
static Common::ThreadQueueList<Thread*, THREADPRIO_LOWEST + 1> ready_queue;
-static Thread* current_thread;
+static SharedPtr<Thread> current_thread;
// The first available thread id at startup
static u32 next_thread_id;
@@ -63,7 +63,7 @@ Thread::Thread() {}
Thread::~Thread() {}
Thread* GetCurrentThread() {
- return current_thread;
+ return current_thread.get();
}
/**
@@ -263,6 +263,13 @@ void WaitCurrentThread_ArbitrateAddress(VAddr wait_address) {
thread->status = THREADSTATUS_WAIT_ARB;
}
+void ExitCurrentThread() {
+ Thread* thread = GetCurrentThread();
+ thread->Stop();
+ thread_list.erase(std::remove(thread_list.begin(), thread_list.end(), thread),
+ thread_list.end());
+}
+
/**
* Callback that will wake up the thread it was scheduled for
* @param thread_handle The handle of the thread that's been awoken
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index 238359fc5..d4fefc573 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -253,6 +253,11 @@ void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wa
void WaitCurrentThread_ArbitrateAddress(VAddr wait_address);
/**
+ * Stops the current thread and removes it from the thread_list
+ */
+void ExitCurrentThread();
+
+/**
* Initialize threading
*/
void ThreadingInit();