Struct amy::Timer [] [src]

pub struct Timer { /* fields omitted */ }

An opaque handle to a kernel timer instance.

On Linux this contains a file descriptor created with timerfd_create() On systems using kqueue, a file descriptor is not needed, so it is set to 0.

Methods

impl Timer
[src]

Re-arm a recurring timer.

This method must be called when an interval timer notification is received. If not called, the next timer notification will not be received.

The pattern is to store the timers in a hashmap keyed by their IDs. When a timer id is received, and the timer looked up the user should call arm().

This method doesn't actually change the timing of the recurring timer. An interval timer will fire exactly at the interval specified originally. This just allows the kernel poller to received the timer event and send a notification. On epoll based systems if a timer has already fired because the timer period has elapsed, the kernel poller will be woken up immediately after this call and a notification will be sent. Since this call is a no-op on kqueue based systems, timer notifications will always be sent on time regardless of calls to arm. This should not be a problem in practice as timers should be re-armed before the next timer fires. Otherwise the timer interval is too short to be useful.

Note that this method isn't strictly necessary for kqueue, but due to the semantics of epoll and the usage of timerfd, it is required that this method be called. For portability, any users should always call arm() when an interval timer notification is received.

Trait Implementations

impl Debug for Timer
[src]

Formats the value using the given formatter.

impl Clone for Timer
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl AsRawFd for Timer
[src]

Extracts the raw file descriptor. Read more