diff options
| author | Dan Engelbrecht <[email protected]> | 2026-03-11 16:01:29 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-03-11 16:01:29 +0100 |
| commit | 57816d04b61f6bdc1403583201246abd5883c457 (patch) | |
| tree | 6148371fcc7d98702f0b121a3f40efe4e6bc08d4 /src/zencore/jobqueue.cpp | |
| parent | block scavenge of other downloads that uses an older state file (#822) (diff) | |
| download | zen-57816d04b61f6bdc1403583201246abd5883c457.tar.xz zen-57816d04b61f6bdc1403583201246abd5883c457.zip | |
improved oplog import progress reporting (#825)
Diffstat (limited to 'src/zencore/jobqueue.cpp')
| -rw-r--r-- | src/zencore/jobqueue.cpp | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/src/zencore/jobqueue.cpp b/src/zencore/jobqueue.cpp index d6a8a6479..3e58fb97d 100644 --- a/src/zencore/jobqueue.cpp +++ b/src/zencore/jobqueue.cpp @@ -57,9 +57,10 @@ public: virtual void ReportProgress(std::string_view CurrentOp, std::string_view Details, ptrdiff_t TotalCount, - ptrdiff_t RemainingCount) override + ptrdiff_t RemainingCount, + uint64_t ElapsedTimeMs) override { - Queue->ReportProgress(Id, CurrentOp, Details, TotalCount, RemainingCount); + Queue->ReportProgress(Id, CurrentOp, Details, TotalCount, RemainingCount, ElapsedTimeMs); } }; @@ -265,21 +266,20 @@ public: virtual std::optional<JobDetails> Get(JobId Id) override { auto Convert = [](JobStatus Status, Job& Job) -> JobDetails { - return JobDetails{ - .Name = Job.Name, - .Status = Status, - .State = {.CurrentOp = Job.State.CurrentOp, - .CurrentOpDetails = Job.State.CurrentOpDetails, - .TotalCount = Job.State.TotalCount, - .RemainingCount = Job.State.RemainingCount, - // .CurrentOpPercentComplete = Job.State.CurrentOpPercentComplete, - .Messages = std::move(Job.State.Messages), - .AbortReason = Job.State.AbortReason}, - .CreateTime = JobClock::TimePointFromTick(Job.CreateTick), - .StartTime = JobClock::TimePointFromTick(Job.StartTick), - .EndTime = JobClock::TimePointFromTick(Job.EndTick), - .WorkerThreadId = Job.WorkerThreadId, - .ReturnCode = Job.ReturnCode}; + return JobDetails{.Name = Job.Name, + .Status = Status, + .State = {.CurrentOp = Job.State.CurrentOp, + .CurrentOpDetails = Job.State.CurrentOpDetails, + .TotalCount = Job.State.TotalCount, + .RemainingCount = Job.State.RemainingCount, + .ProgressElapsedTimeMs = Job.State.ProgressElapsedTimeMs, + .Messages = std::move(Job.State.Messages), + .AbortReason = Job.State.AbortReason}, + .CreateTime = JobClock::TimePointFromTick(Job.CreateTick), + .StartTime = JobClock::TimePointFromTick(Job.StartTick), + .EndTime = JobClock::TimePointFromTick(Job.EndTick), + .WorkerThreadId = Job.WorkerThreadId, + .ReturnCode = Job.ReturnCode}; }; std::optional<JobDetails> Result; @@ -320,15 +320,21 @@ public: }); } - void ReportProgress(JobId Id, std::string_view CurrentOp, std::string_view Details, ptrdiff_t TotalCount, ptrdiff_t RemainingCount) + void ReportProgress(JobId Id, + std::string_view CurrentOp, + std::string_view Details, + ptrdiff_t TotalCount, + ptrdiff_t RemainingCount, + uint64_t ElapsedTimeMs) { QueueLock.WithExclusiveLock([&]() { auto It = RunningJobs.find(Id.Id); ZEN_ASSERT(It != RunningJobs.end()); - It->second->State.CurrentOp = CurrentOp; - It->second->State.CurrentOpDetails = Details; - It->second->State.TotalCount = TotalCount; - It->second->State.RemainingCount = RemainingCount; + It->second->State.CurrentOp = CurrentOp; + It->second->State.CurrentOpDetails = Details; + It->second->State.TotalCount = TotalCount; + It->second->State.RemainingCount = RemainingCount; + It->second->State.ProgressElapsedTimeMs = ElapsedTimeMs; }); } @@ -476,13 +482,13 @@ TEST_CASE("JobQueue") { return; } - Context.ReportProgress("going to sleep", "", 100, 100); + Context.ReportProgress("going to sleep", "", 100, 100, (uint64_t)-1); Sleep(5); if (Context.IsCancelled()) { return; } - Context.ReportProgress("going to sleep again", "", 100, 50); + Context.ReportProgress("going to sleep again", "", 100, 50, (uint64_t)-1); if ((I & 0xFF) == 0x10) { zen::ThrowSystemError(8, fmt::format("Job {} forced to fail", I)); @@ -492,7 +498,7 @@ TEST_CASE("JobQueue") { return; } - Context.ReportProgress("done", "", 100, 0); + Context.ReportProgress("done", "", 100, 0, (uint64_t)-1); }); ZEN_UNUSED(Id); }, |