Home
Ratchet Library :: API Reference
API  ·  Manual

Module ratchet.timerfd

The timerfd library provides an advanced timer interface using the system library of the same name. Timers from this library can be set to fire repeatedly and provide counts if several fires have taken place since last check. These functions can fail, see error handling section in manual for details.

Functions

close (self) Closes the timerfd internal file descriptor.
get_fd (self) Returns the file descriptor for the internal timerfd object.
gettime (self) Returns information about the current timer, corresponding to the timerfd_gettime() system call.
new (clock) Returns a new timerfd object.
read (self) Pauses the current thread until the next firing of the timer.
settime (self, wait_seconds, interval_seconds, flag) Arms (or disarms) the timerfd object.


Functions

close (self)
Closes the timerfd internal file descriptor. This is called automatically when the timerfd object is collected, for convenience.

Parameters

  • self: the timerfd object.
get_fd (self)
Returns the file descriptor for the internal timerfd object.

Parameters

  • self: the timerfd object.

Return value:

the file descriptor.
gettime (self)
Returns information about the current timer, corresponding to the timerfd_gettime() system call. This would be the number of seconds until the next fire of the timer.

Parameters

  • self: the timerfd object.

Return value:

seconds until next timer firing.
new (clock)
Returns a new timerfd object.

Parameters

  • clock: either "monotonic" or "realtime" based on the desired clock type. See man page timerfd_create(2) for details. The default is "monotonic".

Return value:

a new timerfd object.
read (self)
Pauses the current thread until the next firing of the timer. If the timer has fired since the last call to read(), it will return immediately.

Parameters

  • self: the timerfd object.

Return value:

the number of fires since last call to read().
settime (self, wait_seconds, interval_seconds, flag)
Arms (or disarms) the timerfd object. This function corresponds to the timerfd_settime() system call. If wait_seconds is not given or nil, the timer is disarmed.

Parameters

  • self: the timerfd object.
  • wait_seconds: seconds until first fire of timerfd.
  • interval_seconds: seconds until subsequent fires.
  • flag: either "relative" or "absolute", default "relative".