24#ifndef LELY_IO2_CLOCK_HPP_
25#define LELY_IO2_CLOCK_HPP_
37 using duration = ::std::chrono::nanoseconds;
38 using time_point = ::std::chrono::time_point<Clock, duration>;
42 operator io_clock_t*()
const noexcept {
return clock_; }
46 getres(::std::error_code& ec)
const noexcept {
49 timespec res = {0, 0};
55 return util::from_timespec(res);
63 if (ec) throw ::std::system_error(ec,
"getres");
69 gettime(::std::error_code& ec)
const noexcept {
78 return time_point(util::from_timespec(ts));
86 if (ec) throw ::std::system_error(ec,
"gettime");
92 settime(
const time_point& t, ::std::error_code& ec)
noexcept {
95 auto ts = util::to_timespec(t);
106 ::std::error_code ec;
108 if (ec) throw ::std::system_error(ec,
"settime");
An abstract clock. This class is a wrapper around #io_clock_t*.
void settime(const time_point &t)
duration getres(::std::error_code &ec) const noexcept
time_point gettime() const
void settime(const time_point &t, ::std::error_code &ec) noexcept
time_point gettime(::std::error_code &ec) const noexcept
This header file is part of the I/O library; it contains the abstract clock interface.
int io_clock_settime(io_clock_t *clock, const struct timespec *tp)
Sets the time value of the specified clock.
int io_clock_gettime(const io_clock_t *clock, struct timespec *tp)
Obtains the current time value of the specified clock.
int io_clock_getres(const io_clock_t *clock, struct timespec *res)
Obtains the resolution of the specified clock.
const struct io_clock_vtbl *const io_clock_t
An abstract clock.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
This header file is part of the utilities library; it contains C++ convenience functions for creating...
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
This header file is part of the utilities library; it contains the time function declarations.