This subclass of IO::Async::Timer implements one-shot fixed delays. The object implements a countdown timer, which invokes its callback after the given period from when it was started. After it has expired the Timer may be started again, when it will wait the same period then invoke the callback again. A timer that is currently running may be stopped or reset.

Because the reset method restarts a running countdown timer back to its full period, it can be used to implement a watchdog timer. This is a timer which will not expire provided the method is called at least as often as it is configured. If the method fails to be called, the timer will eventually expire and run its callback.

For example, to expire an accepted connection after 30 seconds of inactivity:

Rather than setting up a lexical variable to store the Stream so that the Timer's on_expire closure can call close on it, the parent/child relationship between the two Notifier objects is used. At the time the Timer on_expire closure is invoked, it will have been added as a child notifier of the Stream; this means the Timer's parent method will return the Stream Notifier. This enables it to call close without needing to capture a lexical variable, which would create a cyclic reference.

The on_expire event fires a fixed delay after the start method has begun the countdown. The start method can be invoked again at some point during the on_expire handling code, to create a timer that invokes its code regularly a fixed delay after the previous invocation has finished. This creates an arrangement similar to an IO::Async::Timer::Periodic, except that it will wait until the previous invocation has indicated it is finished, before starting the countdown for the next call.