ClickHouse/src/Common/TimerDescriptor.h

33 lines
717 B
C++
Raw Normal View History

2020-12-03 12:21:10 +00:00
#pragma once
2020-12-15 18:04:12 +00:00
#if defined(OS_LINUX)
2020-12-03 12:21:10 +00:00
#include <Poco/Timespan.h>
namespace DB
{
2020-12-18 15:12:31 +00:00
/// Wrapper over timerfd.
2020-12-03 12:21:10 +00:00
class TimerDescriptor
{
private:
int timer_fd;
public:
2021-01-19 19:21:06 +00:00
explicit TimerDescriptor(int clockid = CLOCK_MONOTONIC, int flags = 0);
2020-12-03 12:21:10 +00:00
~TimerDescriptor();
TimerDescriptor(const TimerDescriptor &) = delete;
TimerDescriptor & operator=(const TimerDescriptor &) = delete;
TimerDescriptor(TimerDescriptor && other) noexcept;
2020-12-03 12:21:10 +00:00
TimerDescriptor & operator=(TimerDescriptor &&) = default;
int getDescriptor() const { return timer_fd; }
void reset() const;
void drain() const;
void setRelative(uint64_t usec) const;
2021-04-29 16:11:20 +00:00
void setRelative(Poco::Timespan timespan) const;
2020-12-03 12:21:10 +00:00
};
}
2020-12-15 18:04:12 +00:00
#endif