31 std::unique_lock<std::timed_mutex> lock(
mutex_);
45 std::unique_lock<std::timed_mutex> lock(
mutex_);
50 std::unique_lock<std::timed_mutex> lock(
mutex_);
52 steady_clock::time_point tm = steady_clock::now();
74 tm = steady_clock::now();
84 : next_timeout(_next_timeout), period(_period),
85 task(_task), own_task(_own_task) { }
95 const std::chrono::milliseconds&
period,
97 : profiler_(profiler), task_(task) {
void emplace(Args &&... args)
add an items in the PQ.
ProfileTask * task_
task to register and unregister
std::thread thread_
thread for profiling (only run on top-level loggers)
Timer(const steady_clock::time_point &_next_timeout, const milliseconds &_period, ProfileTask *_task, bool _own_task)
bool operator<(const Timer &b) const
static constexpr bool g_profile_thread
global flag to enable background profiler thread
bool own_task
delete task on deletion
void pop()
remove the top item in the PQ
bool Remove(ProfileTask *task)
Unregister a regularly scheduled callback.
milliseconds period
interval period for rescheduling
virtual void RunTask(const std::chrono::steady_clock::time_point &tp)=0
method called by ProfileThread.
steady_clock::time_point next_timeout
timepoint of next run
void Worker()
the thread worker function
std::timed_mutex mutex_
cv/mutex pair to signal thread to terminate
ProfileThread & profiler_
profiler at which the task was registered
const_reference top() const
return reference to top item in PQ
void Add(const Period &period, ProfileTask *task, bool own_task=false)
Register a regularly scheduled callback.
ProfileTask * task
callback
std::condition_variable_any cv_
cv/mutex pair to signal thread to terminate
std::atomic< bool > terminate_
flag to terminate profiling thread
struct for timer callbacks
ProfileTaskRegistration(const std::chrono::milliseconds &period, ProfileThread &profiler, ProfileTask *task)
Container & container()
direct access to heap container
~ProfileTaskRegistration()
TimerPQ tasks_
priority queue of interval scheduled callbacks
bool empty() const
check if PQ is empty
size_t erase(Functor &&f)
std::chrono::milliseconds milliseconds