aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/jobqueue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/jobqueue.cpp')
-rw-r--r--src/zencore/jobqueue.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/zencore/jobqueue.cpp b/src/zencore/jobqueue.cpp
index 3e58fb97d..40e4e2162 100644
--- a/src/zencore/jobqueue.cpp
+++ b/src/zencore/jobqueue.cpp
@@ -12,10 +12,9 @@
#endif // ZEN_WITH_TESTS
ZEN_THIRD_PARTY_INCLUDES_START
+#include <EASTL/deque.h>
#include <gsl/gsl-lite.hpp>
ZEN_THIRD_PARTY_INCLUDES_END
-
-#include <deque>
#include <thread>
#include <unordered_map>
@@ -93,7 +92,7 @@ public:
{
NewJobId = IdGenerator.fetch_add(1);
}
- RefPtr<Job> NewJob(new Job());
+ Ref<Job> NewJob(new Job());
NewJob->Queue = this;
NewJob->Name = Name;
NewJob->Callback = std::move(JobFunc);
@@ -124,7 +123,7 @@ public:
QueueLock.WithExclusiveLock([&]() {
if (auto It = std::find_if(QueuedJobs.begin(),
QueuedJobs.end(),
- [NewJobId](const RefPtr<Job>& Job) { return Job->Id.Id == NewJobId; });
+ [NewJobId](const Ref<Job>& Job) { return Job->Id.Id == NewJobId; });
It != QueuedJobs.end())
{
QueuedJobs.erase(It);
@@ -156,7 +155,7 @@ public:
Result = true;
return;
}
- if (auto It = std::find_if(QueuedJobs.begin(), QueuedJobs.end(), [&Id](const RefPtr<Job>& Job) { return Job->Id.Id == Id.Id; });
+ if (auto It = std::find_if(QueuedJobs.begin(), QueuedJobs.end(), [&Id](const Ref<Job>& Job) { return Job->Id.Id == Id.Id; });
It != QueuedJobs.end())
{
ZEN_DEBUG("Cancelling queued background job {}:'{}'", (*It)->Id.Id, (*It)->Name);
@@ -301,7 +300,7 @@ public:
AbortedJobs.erase(It);
return;
}
- if (auto It = std::find_if(QueuedJobs.begin(), QueuedJobs.end(), [&Id](const RefPtr<Job>& Job) { return Job->Id.Id == Id.Id; });
+ if (auto It = std::find_if(QueuedJobs.begin(), QueuedJobs.end(), [&Id](const Ref<Job>& Job) { return Job->Id.Id == Id.Id; });
It != QueuedJobs.end())
{
Result = Convert(JobStatus::Queued, *(*It));
@@ -340,20 +339,20 @@ public:
std::atomic_uint64_t IdGenerator = 1;
- std::atomic_bool InitializedFlag = false;
- RwLock QueueLock;
- std::deque<RefPtr<Job>> QueuedJobs;
- std::unordered_map<uint64_t, RefPtr<Job>> RunningJobs;
- std::unordered_map<uint64_t, RefPtr<Job>> CompletedJobs;
- std::unordered_map<uint64_t, RefPtr<Job>> AbortedJobs;
+ std::atomic_bool InitializedFlag = false;
+ RwLock QueueLock;
+ eastl::deque<Ref<Job>> QueuedJobs;
+ std::unordered_map<uint64_t, Ref<Job>> RunningJobs;
+ std::unordered_map<uint64_t, Ref<Job>> CompletedJobs;
+ std::unordered_map<uint64_t, Ref<Job>> AbortedJobs;
WorkerThreadPool WorkerPool;
Latch WorkerCounter;
void Worker()
{
- int CurrentThreadId = GetCurrentThreadId();
- RefPtr<Job> CurrentJob;
+ int CurrentThreadId = GetCurrentThreadId();
+ Ref<Job> CurrentJob;
QueueLock.WithExclusiveLock([&]() {
if (!QueuedJobs.empty())
{