1IO::Async::Timer::PerioUdsiecr(3C)ontributed Perl DocumeInOt:a:tAisoynnc::Timer::Periodic(3)
2
3
4

NAME

6       "IO::Async::Timer::Periodic" - event callback at regular intervals
7

SYNOPSIS

9        use IO::Async::Timer::Periodic;
10
11        use IO::Async::Loop;
12        my $loop = IO::Async::Loop->new();
13
14        my $timer = IO::Async::Timer::Periodic->new(
15           interval => 60,
16
17           on_tick => sub {
18              print "You've had a minute\n";
19           },
20        );
21
22        $timer->start;
23
24        $loop->add( $timer );
25
26        $loop->loop_forever;
27

DESCRIPTION

29       This module provides a subclass of IO::Async::Timer for implementing
30       repeating events at regular intervals. The object invokes its callback
31       at regular clock intervals. The timing is not subject to how long it
32       takes the callback to execute, but runs at regular intervals beginning
33       at the time the timer was started, then adding each interval
34       thereafter.
35
36       For a "Timer" object that only runs a callback once, after a given
37       delay, see instead IO::Async::Timer::Countdown.
38
39       This object may be used in one of two ways; with a callback function,
40       or as a base class.
41
42       Callbacks
43           If the "on_tick" key is supplied to the constructor, it should
44           contain a CODE reference to a callback function to be invoked at
45           the appropriate time:
46
47            $on_tick->( $self )
48
49       Base Class
50           If a subclass is built, then it can override the "on_tick" method.
51
52            $self->on_tick()
53

PARAMETERS

55       The following named parameters may be passed to "new" or "configure":
56
57       on_tick => CODE
58               CODE reference to callback to invoke each interval. If not
59               supplied, the subclass method will be called instead.
60
61       interval => NUM
62               The interval in seconds between invocations of the callback or
63               method. Cannot be changed if the timer is running.
64
65       Once constructed, the timer object will need to be added to the "Loop"
66       before it will work. It will also need to be started by the "start"
67       method.
68

AUTHOR

70       Paul Evans <leonerd@leonerd.org.uk>
71
72
73
74perl v5.12.1                      2010-06-09     IO::Async::Timer::Periodic(3)
Impressum