summaryrefslogtreecommitdiff
path: root/src/ingestor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ingestor.cpp')
-rw-r--r--src/ingestor.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ingestor.cpp b/src/ingestor.cpp
index ba89991..692ddd2 100644
--- a/src/ingestor.cpp
+++ b/src/ingestor.cpp
@@ -223,17 +223,21 @@ namespace WebStat {
Ingestor::runJobsAsNeeded()
{
auto runJobAsNeeded = [this, now = Job::LastRunTime::clock::now()](Job & job, auto freq) {
- if (!job.currentRun && expired(job.lastRun, freq, now)) {
- job.currentRun.emplace([this, now, freq, &job]() {
+ if (job.currentRun) {
+ if (job.currentRun->valid()) {
try {
- (this->*job.impl)();
+ job.currentRun->get();
job.lastRun = now;
}
catch (const std::exception &) {
// Error, retry in half the frequency
job.lastRun = now - (freq / 2);
}
- });
+ job.currentRun.reset();
+ }
+ }
+ else if (expired(job.lastRun, freq, now)) {
+ job.currentRun.emplace(std::async(job.impl, this));
}
};
runJobAsNeeded(ingestParkedLines, settings.freqIngestParkedLines);