mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 05:26:24 +02:00
ThreadManager cleanups
This commit is contained in:
1 parent
8e9cdf97cf
commit
0d9d360b07
2 files changed
+13
-4
No files matched your search
@@ -98,7 +98,7 @@ static void WorkerThreadFunc(GlobalThreadContext *global, ThreadContext *thread)
|
||||
}
|
||||
|
||||
void ThreadManager::Init(int numRealCores, int numLogicalCoresPerCpu) {
|
||||
if (!global_->threads_.empty()) {
|
||||
if (IsInitialized()) {
|
||||
Teardown();
|
||||
}
|
||||
|
||||
@@ -118,6 +118,8 @@ void ThreadManager::Init(int numRealCores, int numLogicalCoresPerCpu) {
|
||||
}
|
||||
|
||||
void ThreadManager::EnqueueTask(Task *task, TaskType taskType) {
|
||||
_assert_msg_(IsInitialized(), "ThreadManager not initialized");
|
||||
|
||||
int maxThread;
|
||||
int threadOffset = 0;
|
||||
if (taskType == TaskType::CPU_COMPUTE) {
|
||||
@@ -158,7 +160,7 @@ void ThreadManager::EnqueueTask(Task *task, TaskType taskType) {
|
||||
}
|
||||
|
||||
void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task, TaskType taskType) {
|
||||
_assert_(threadNum >= 0 && threadNum < (int)global_->threads_.size());
|
||||
_assert_msg_(threadNum >= 0 && threadNum < (int)global_->threads_.size(), "Bad threadnum or not initialized");
|
||||
ThreadContext *thread = global_->threads_[threadNum];
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(thread->mutex);
|
||||
@@ -172,5 +174,9 @@ int ThreadManager::GetNumLooperThreads() const {
|
||||
}
|
||||
|
||||
void ThreadManager::TryCancelTask(uint64_t taskID) {
|
||||
// Do nothing
|
||||
// Do nothing for now, just let it finish.
|
||||
}
|
||||
|
||||
bool ThreadManager::IsInitialized() const {
|
||||
return !global_->threads_.empty();
|
||||
}
|
||||
@@ -48,6 +48,8 @@ public:
|
||||
void EnqueueTaskOnThread(int threadNum, Task *task, TaskType taskType);
|
||||
void Teardown();
|
||||
|
||||
bool IsInitialized() const;
|
||||
|
||||
// Currently does nothing. It will always be best-effort - maybe it cancels,
|
||||
// maybe it doesn't. Note that the id is the id() returned by the task. You need to make that
|
||||
// something meaningful yourself.
|
||||
@@ -58,7 +60,8 @@ public:
|
||||
int GetNumLooperThreads() const;
|
||||
|
||||
private:
|
||||
GlobalThreadContext *global_ = nullptr;
|
||||
// This is always pointing to a context, initialized in the constructor.
|
||||
GlobalThreadContext *global_;
|
||||
|
||||
int numThreads_ = 0;
|
||||
int numComputeThreads_ = 0;
|
||||
|
||||
Reference in new issue
Block a user