15 #ifndef THRILL_COMMON_PROFILE_THREAD_HEADER 16 #define THRILL_COMMON_PROFILE_THREAD_HEADER 24 #include <condition_variable> 48 template <
typename Period>
50 std::unique_lock<std::timed_mutex> lock(
mutex_);
52 std::chrono::duration_cast<milliseconds>(period),
71 std::condition_variable_any
cv_;
84 Timer(
const steady_clock::time_point& _next_timeout,
104 #endif // !THRILL_COMMON_PROFILE_THREAD_HEADER void emplace(Args &&... args)
add an items in the PQ.
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
bool own_task
delete task on deletion
bool Remove(ProfileTask *task)
Unregister a regularly scheduled callback.
std::chrono::steady_clock steady_clock
milliseconds period
interval period for rescheduling
void Worker()
the thread worker function
steady_clock::time_point next_timeout
timepoint of next run
std::timed_mutex mutex_
cv/mutex pair to signal thread to terminate
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
ProfileThread & operator=(const ProfileThread &)=delete
non-copyable: delete assignment operator
TimerPQ tasks_
priority queue of interval scheduled callbacks
std::chrono::milliseconds milliseconds