summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ingestor.cpp4
-rw-r--r--src/ingestor.hpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/ingestor.cpp b/src/ingestor.cpp
index fe8d38c..5f9fa60 100644
--- a/src/ingestor.cpp
+++ b/src/ingestor.cpp
@@ -426,7 +426,9 @@ namespace WebStat {
}
}
else if (expired(job.lastRun, freq, now)) {
- job.currentRun.emplace(std::async(job.impl, this));
+ if (!job.cond || std::invoke(job.cond, this)) {
+ job.currentRun.emplace(std::async(job.impl, this));
+ }
}
};
runJobAsNeeded(ingestParkedLines, settings.freqIngestParkedLines);
diff --git a/src/ingestor.hpp b/src/ingestor.hpp
index dd803ce..a51c46c 100644
--- a/src/ingestor.hpp
+++ b/src/ingestor.hpp
@@ -46,10 +46,12 @@ namespace WebStat {
using LastRunTime = std::chrono::system_clock::time_point;
using Result = std::function<unsigned int()>;
using Impl = Result (Ingestor::*)();
+ using Cond = bool (Ingestor::*)();
- explicit Job(Impl jobImpl) : impl(jobImpl) { }
+ explicit Job(Impl jobImpl, Cond jobCond = nullptr) : impl {jobImpl}, cond {jobCond} { }
const Impl impl;
+ const Cond cond;
LastRunTime lastRun {LastRunTime::clock::now()};
std::optional<std::future<Result>> currentRun;
};