File PeriodicBackgroundThread.h

Defines

DEFAULT_BACKGROUND_INTERVAL_SECONDS
namespace faabric
namespace util
class PeriodicBackgroundThread
#include <PeriodicBackgroundThread.h>

Wrapper around periodic background thread that repeatedly does some arbitrary work after a given interval.

Subclassed by faabric::planner::KeepAliveThread, faabric::scheduler::SchedulerReaperThread

Public Functions

void start(int intervalSecondsIn)

Start the background thread with the given wake-up interval in seconds.

void stop()

Stop and wait for this thread to finish.

virtual void doWork() = 0
virtual void tidyUp()
inline int getIntervalSeconds()

Protected Attributes

int intervalSeconds = DEFAULT_BACKGROUND_INTERVAL_SECONDS

Private Members

std::unique_ptr<std::jthread> workThread = nullptr
std::mutex mx
std::condition_variable_any timeoutCv