1 #ifndef INCLUDE_AL_PERIODIC_THREAD_HPP
2 #define INCLUDE_AL_PERIODIC_THREAD_HPP
48 #include "al/system/al_Thread.hpp"
49 #include "al/system/al_Time.hpp"
96 void start(std::function<
void(
void* data)>
function,
97 void* userData =
nullptr);
110 static void* sPeriodicFunc(
void* userData);
114 al_nsec mTimeCurr, mTimePrev;
120 std::function<void(
void* data)> mFunction;
Thread that calls a function periodically.
PeriodicThread & autocorrect(float factor)
Set autocorrection factor.
PeriodicThread(double periodSec=1)
PeriodicThread & period(double sec)
Set period, in seconds.
void stop()
Stop the thread.
void start(std::function< void(void *data)> function, void *userData=nullptr)
Start calling the supplied function periodically.
PeriodicThread(const PeriodicThread &other)
Copy constructor.
void start(ThreadFunction &func)
Start calling the supplied function periodically.
double period() const
Get period, in seconds.
bool running() const
True if timer thread is running.
Function object interface used by thread.