Module tch.timerfd
Lua C module exposing timers that notify via file descriptors.
See timerfd_create(2) for more information on timers that notify via file descriptors.
Functions
close(fd) | Close the underlying file descriptor of a timer_fd. |
create() | Create a new timer_fd. |
fd(timer_fd) | Return the underlying file descriptor of a timer_fd. |
read(fd) | Read from the underlying file descriptor of a timer_fd. |
settime(timer_fd, secs) | Set the timing behaviour on a given timer_fd. |
Functions
- close(fd)
-
Close the underlying file descriptor of a timer_fd. By closing the
underlying file descriptor, the timer should be disarmed and its
resources freed by the kernel.
Parameters:
- fd An underlying file descriptor of a timer_fd.
Returns:
- nil
- string Error message
- create()
-
Create a new timer_fd.
Returns:
-
timer_fd
The new timer_fd.
Or
- nil
- string Error message
- fd(timer_fd)
-
Return the underlying file descriptor of a timer_fd.
Parameters:
- timer_fd A timer_fd struct.
Returns:
-
int
The file descriptor.
Or
- nil
- string Error message
- read(fd)
-
Read from the underlying file descriptor of a timer_fd.
Parameters:
- fd An underlying file descriptor of a timer_fd.
Returns:
-
int
How many times the timer has fired since the last time we've read from it.
Or
- nil
- string Error message
- settime(timer_fd, secs)
-
Set the timing behaviour on a given timer_fd. Both the interval
and the first deadline are set to the given value, effectively creating
a periodic timer.
Parameters:
- timer_fd A timer_fd struct.
- secs How many seconds the timer should use.
Returns:
- nil
- string Error message