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:
|
2024-07-27 18:50:21 +00:00
|
|
|
TimerDescriptor();
|
2020-12-03 12:21:10 +00:00
|
|
|
~TimerDescriptor();
|
|
|
|
|
|
|
|
TimerDescriptor(const TimerDescriptor &) = delete;
|
|
|
|
TimerDescriptor & operator=(const TimerDescriptor &) = delete;
|
2022-02-25 19:04:48 +00:00
|
|
|
TimerDescriptor(TimerDescriptor && other) noexcept;
|
2023-09-18 16:44:59 +00:00
|
|
|
TimerDescriptor & operator=(TimerDescriptor &&) noexcept;
|
2020-12-03 12:21:10 +00:00
|
|
|
|
|
|
|
int getDescriptor() const { return timer_fd; }
|
|
|
|
|
|
|
|
void reset() const;
|
|
|
|
void drain() const;
|
2021-08-23 18:17:11 +00:00
|
|
|
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
|