.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "IO::Async::Timer 3pm" .TH IO::Async::Timer 3pm 2024-02-04 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME "IO::Async::Timer" \- base class for Notifiers that use timed delays .SH DESCRIPTION .IX Header "DESCRIPTION" This module provides a subclass of IO::Async::Notifier for implementing notifiers that use timed delays. For specific implementations, see one of the subclasses: .IP \(bu 8 IO::Async::Timer::Absolute \- event callback at a fixed future time .IP \(bu 8 IO::Async::Timer::Countdown \- event callback after a fixed delay .IP \(bu 8 IO::Async::Timer::Periodic \- event callback at regular intervals .SH CONSTRUCTOR .IX Header "CONSTRUCTOR" .SS new .IX Subsection "new" .Vb 1 \& $timer = IO::Async::Timer\->new( %args ); .Ve .PP Constructs a particular subclass of \f(CW\*(C`IO::Async::Timer\*(C'\fR object, and returns it. This constructor is provided for backward compatibility to older code which doesn't use the subclasses. New code should directly construct a subclass instead. .IP "mode => STRING" 8 .IX Item "mode => STRING" The type of timer to create. Currently the only allowed mode is \f(CW\*(C`countdown\*(C'\fR but more types may be added in the future. .PP Once constructed, the \f(CW\*(C`Timer\*(C'\fR will need to be added to the \f(CW\*(C`Loop\*(C'\fR before it will work. It will also need to be started by the \f(CW\*(C`start\*(C'\fR method. .SH METHODS .IX Header "METHODS" .SS is_running .IX Subsection "is_running" .Vb 1 \& $running = $timer\->is_running; .Ve .PP Returns true if the Timer has been started, and has not yet expired, or been stopped. .SS start .IX Subsection "start" .Vb 1 \& $timer\->start; .Ve .PP Starts the Timer. Throws an error if it was already running. .PP If the Timer is not yet in a Loop, the actual start will be deferred until it is added. Once added, it will be running, and will expire at the given duration after the time it was added. .PP As a convenience, \f(CW$timer\fR is returned. This may be useful for starting timers at construction time: .PP .Vb 1 \& $loop\->add( IO::Async::Timer\->new( ... )\->start ); .Ve .SS stop .IX Subsection "stop" .Vb 1 \& $timer\->stop; .Ve .PP Stops the Timer if it is running. If it has not yet been added to the \f(CW\*(C`Loop\*(C'\fR but there is a start pending, this will cancel it. .SH AUTHOR .IX Header "AUTHOR" Paul Evans