// Copyright (2019-2023) Paul Scherrer Institute #include "PreviewCounter.h" PreviewCounter::PreviewCounter(std::chrono::microseconds in_period) : period(in_period), last_preview() {} bool PreviewCounter::GeneratePreview() { std::unique_lock ul(m); auto now = std::chrono::system_clock::now(); if (now > last_preview + period) { last_preview = now; return true; } else return false; }