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->run;
27

DESCRIPTION

29       This subclass of IO::Async::Timer implements repeating events at
30       regular clock intervals. The timing may or may not be subject to how
31       long it takes the callback to execute. Iterations may be rescheduled
32       runs at fixed regular intervals beginning at the time the timer was
33       started, or by a fixed delay after the previous code has finished
34       executing.
35
36       For a "Timer" object that only runs a callback once, after a given
37       delay, see instead IO::Async::Timer::Countdown. A Countdown timer can
38       also be used to create repeating events that fire at a fixed delay
39       after the previous event has finished processing. See als the examples
40       in "IO::Async::Timer::Countdown".
41

EVENTS

43       The following events are invoked, either using subclass methods or CODE
44       references in parameters:
45
46   on_tick
47       Invoked on each interval of the timer.
48

PARAMETERS

50       The following named parameters may be passed to "new" or "configure":
51
52   on_tick => CODE
53       CODE reference for the "on_tick" event.
54
55   interval => NUM
56       The interval in seconds between invocations of the callback or method.
57       Cannot be changed if the timer is running.
58
59   first_interval => NUM
60       Optional. If defined, the interval in seconds after calling the "start"
61       method before the first invocation of the callback or method.
62       Thereafter, the regular "interval" will be used. If not supplied, the
63       first interval will be the same as the others.
64
65       Even if this value is zero, the first invocation will be made
66       asynchronously, by the containing "Loop" object, and not synchronously
67       by the "start" method itself.
68
69   reschedule => STRING
70       Optional. Must be one of "hard", "skip" or "drift". Defines the
71       algorithm used to reschedule the next invocation.
72
73       "hard" schedules each iteration at the fixed interval from the previous
74       iteration's schedule time, ensuring a regular repeating event.
75
76       "skip" schedules similarly to "hard", but skips over times that have
77       already passed. This matters if the duration is particularly short and
78       there's a possibility that times may be missed, or if the entire
79       process is stopped and resumed by "SIGSTOP" or similar.
80
81       "drift" schedules each iteration at the fixed interval from the time
82       that the previous iteration's event handler returns. This allows it to
83       slowly drift over time and become desynchronised with other events of
84       the same interval or multiples/fractions of it.
85
86       Once constructed, the timer object will need to be added to the "Loop"
87       before it will work. It will also need to be started by the "start"
88       method.
89

AUTHOR

91       Paul Evans <leonerd@leonerd.org.uk>
92
93
94
95perl v5.30.0                      2019-07-26     IO::Async::Timer::Periodic(3)
Impressum