mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 05:26:24 +02:00
Get rid of the PrioritizedWorkQueue. Instead just queue tasks on the ThreadManager.
This commit is contained in:
1 parent
34f8fc557f
commit
446c2c027e
17 files changed
+102
-293
No files matched your search
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// The new threadpool.
|
||||
|
||||
// To help future smart scheduling.
|
||||
@@ -8,12 +10,27 @@ enum class TaskType {
|
||||
IO_BLOCKING,
|
||||
};
|
||||
|
||||
// Implement this to make something that you can run on the thread manager.
|
||||
class Task {
|
||||
public:
|
||||
virtual ~Task() {}
|
||||
virtual void run() = 0;
|
||||
virtual bool cancellable() { return false; }
|
||||
virtual void cancel() {}
|
||||
virtual void Run() = 0;
|
||||
virtual bool Cancellable() { return false; }
|
||||
virtual void Cancel() {}
|
||||
virtual float Priority() { return 1.0f; }
|
||||
virtual uint64_t id() { return 0; }
|
||||
};
|
||||
|
||||
class Waitable {
|
||||
public:
|
||||
virtual ~Waitable() {}
|
||||
|
||||
virtual void Wait() = 0;
|
||||
|
||||
void WaitAndRelease() {
|
||||
Wait();
|
||||
delete this;
|
||||
}
|
||||
};
|
||||
|
||||
struct ThreadContext;
|
||||
@@ -29,8 +46,9 @@ public:
|
||||
void EnqueueTaskOnThread(int threadNum, Task *task, TaskType taskType = TaskType::CPU_COMPUTE);
|
||||
|
||||
// Currently does nothing. It will always be best-effort - maybe it cancels,
|
||||
// maybe it doesn't.
|
||||
void TryCancelTask(Task *task);
|
||||
// maybe it doesn't. Note that the id is the id() returned by the task. You need to make that
|
||||
// something meaningful yourself.
|
||||
void TryCancelTask(uint64_t id);
|
||||
|
||||
// Parallel loops get to use half the threads,
|
||||
// so we still have some worker threads for other tasks.
|
||||
|
||||
Reference in new issue
Block a user