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]

[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. 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.

On Linux timers are file descriptors registered with epoll. Since we use edge triggering we need to read the file descriptors to change their state. Note that even if we used level triggering we'd still need to do this, but for a different reason. The timer would fire indefinitely as ready in the level triggered case, rather than never firing again as in the edge triggered case.

Trait Implementations

impl Debug for Timer
[src]

[src]

Formats the value using the given formatter. Read more

impl Drop for Timer
[src]

[src]

Executes the destructor for this type. Read more

impl AsRawFd for Timer
[src]

[src]

Extracts the raw file descriptor. Read more

Auto Trait Implementations

impl Send for Timer

impl Sync for Timer