ClickHouse/src/Common/TimerDescriptor.h

32 lines
677 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 &&) = default;
TimerDescriptor & operator=(TimerDescriptor &&) = default;
int getDescriptor() const { return timer_fd; }
void reset() const;
void drain() const;
void setRelative(const Poco::Timespan & timespan) const;
};
}
2020-12-15 18:04:12 +00:00
#endif