summaryrefslogtreecommitdiff
path: root/Runtime/Threading/JobSystem.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-25 23:29:21 +0800
committerchai <chaifix@163.com>2021-10-25 23:29:21 +0800
commit7ecf913256fb396e3027aac3318d996a716a52ef (patch)
tree4540835c881a63b665e2a692bf30115fd29e8bb0 /Runtime/Threading/JobSystem.cpp
parent0816cd70ca1a213b6ed872bcf3c0bf0912473722 (diff)
+ job system
Diffstat (limited to 'Runtime/Threading/JobSystem.cpp')
-rw-r--r--Runtime/Threading/JobSystem.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/Runtime/Threading/JobSystem.cpp b/Runtime/Threading/JobSystem.cpp
new file mode 100644
index 0000000..a026300
--- /dev/null
+++ b/Runtime/Threading/JobSystem.cpp
@@ -0,0 +1,43 @@
+#include "JobSystem.h"
+
+JobSystem::JobSystem()
+{
+
+}
+
+JobSystem::~JobSystem()
+{
+
+}
+
+void JobSystem::Initilize(int workThreadCount)
+{
+ if (workThreadCount <= 0)
+ return;
+
+ for (int i = 0; i < workThreadCount; ++i)
+ {
+ WorkThread* thread = new WorkThread();
+ thread->Resume();
+ m_Threads.push_back(thread);
+ }
+}
+
+void JobSystem::Dispatch(void* param)
+{
+ for (int i = 0; i < m_Threads.size(); ++i)
+ {
+ m_Threads[i]->Dispatch(param);
+ }
+}
+
+void JobSystem::AddJobAtEnd(Job* job)
+{
+ WorkThread* thread = SelectThread();
+ thread->AddJobAtEnd(job);
+}
+
+WorkThread* JobSystem::SelectThread()
+{
+ return m_Threads[0];
+} \ No newline at end of file