From 7ecf913256fb396e3027aac3318d996a716a52ef Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Oct 2021 23:29:21 +0800 Subject: + job system --- Runtime/Threading/JobSystem.cpp | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Runtime/Threading/JobSystem.cpp (limited to 'Runtime/Threading/JobSystem.cpp') 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 -- cgit v1.1-26-g67d0