ClickHouse/src/Common/TimerDescriptor.h
2021-02-15 16:21:36 +03:00

32 lines
673 B
C++

#pragma once
#if defined(OS_LINUX)
#include <Poco/Timespan.h>
namespace DB
{
/// Wrapper over timerfd.
class TimerDescriptor
{
private:
int timer_fd;
public:
explicit TimerDescriptor(int clockid = CLOCK_MONOTONIC, int flags = 0);
~TimerDescriptor();
TimerDescriptor(const TimerDescriptor &) = delete;
TimerDescriptor & operator=(const TimerDescriptor &) = delete;
TimerDescriptor(TimerDescriptor && other);
TimerDescriptor & operator=(TimerDescriptor &&) = default;
int getDescriptor() const { return timer_fd; }
void reset() const;
void drain() const;
void setRelative(const Poco::Timespan & timespan) const;
};
}
#endif