mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-04 03:35:19 +02:00
Add facility to run tasks on dedicated threads using the ThreadManager interface.
Useful for things that should be run ASAP even if the threadpool is full, at a small extra cost. (Not recommended for very small tasks). Considering using this to resolve the deadlocks in #16802.
This commit is contained in:
@@ -217,6 +217,16 @@ void ThreadManager::Init(int numRealCores, int numLogicalCoresPerCpu) {
|
||||
}
|
||||
|
||||
void ThreadManager::EnqueueTask(Task *task) {
|
||||
if (task->Type() == TaskType::DEDICATED_THREAD) {
|
||||
std::thread th([=](Task *task) {
|
||||
SetCurrentThreadName("DedicatedThreadTask");
|
||||
task->Run();
|
||||
task->Release();
|
||||
}, task);
|
||||
th.detach();
|
||||
return;
|
||||
}
|
||||
|
||||
_assert_msg_(IsInitialized(), "ThreadManager not initialized");
|
||||
|
||||
int minThread;
|
||||
@@ -270,6 +280,8 @@ void ThreadManager::EnqueueTask(Task *task) {
|
||||
}
|
||||
|
||||
void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task) {
|
||||
_assert_msg_(task->Type() != TaskType::DEDICATED_THREAD, "Dedicated thread tasks can't be put on specific threads");
|
||||
|
||||
_assert_msg_(threadNum >= 0 && threadNum < (int)global_->threads_.size(), "Bad threadnum or not initialized");
|
||||
ThreadContext *thread = global_->threads_[threadNum];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user