diff options
| author | Stefan Boberg <[email protected]> | 2026-04-23 18:16:57 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2026-04-23 18:16:57 +0200 |
| commit | 0232b991cd7d8e3a2114ea30e4591dd3e7b65c36 (patch) | |
| tree | 94730e7594fd09ae1fa820391ce311f6daf13905 /src/zencore/jobqueue.cpp | |
| parent | Fix forward declaration order for s_GotSigWinch and SigWinchHandler (diff) | |
| parent | trace: declare Region event name fields as AnsiString (#1012) (diff) | |
| download | archived-zen-sb/zen-help.tar.xz archived-zen-sb/zen-help.zip | |
Merge branch 'main' into sb/zen-helpsb/zen-help
- Combine HelpCommand (this branch) with HistoryCommand (main) in zen CLI dispatcher
- Keep filter-aware TuiPickOne rewrite; adopt main's ASCII arrow glyphs in doc comment
Diffstat (limited to 'src/zencore/jobqueue.cpp')
| -rw-r--r-- | src/zencore/jobqueue.cpp | 27 |
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()) { |