diff options
author | chai <chaifix@163.com> | 2021-10-25 23:29:21 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-25 23:29:21 +0800 |
commit | 7ecf913256fb396e3027aac3318d996a716a52ef (patch) | |
tree | 4540835c881a63b665e2a692bf30115fd29e8bb0 /Runtime/Threading/JobSystem.cpp | |
parent | 0816cd70ca1a213b6ed872bcf3c0bf0912473722 (diff) |
+ job system
Diffstat (limited to 'Runtime/Threading/JobSystem.cpp')
-rw-r--r-- | Runtime/Threading/JobSystem.cpp | 43 |
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 |