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

NAME

6       "IO::Async::Timer::Absolute" - event callback at a fixed future time
7

SYNOPSIS

9        use IO::Async::Timer::Absolute;
10
11        use POSIX qw( mktime );
12
13        use IO::Async::Loop;
14        my $loop = IO::Async::Loop->new;
15
16        my @time = gmtime;
17
18        my $timer = IO::Async::Timer::Absolute->new(
19           time => mktime( 0, 0, 0, $time[3]+1, $time[4], $time[5] ),
20
21           on_expire => sub {
22              print "It's midnight\n";
23              $loop->stop;
24           },
25        );
26
27        $loop->add( $timer );
28
29        $loop->run;
30

DESCRIPTION

32       This subclass of IO::Async::Timer implements one-shot events at a fixed
33       time in the future. The object waits for a given timestamp, and invokes
34       its callback at that point in the future.
35
36       For a "Timer" object that waits for a delay relative to the time it is
37       started, see instead IO::Async::Timer::Countdown.
38

EVENTS

40       The following events are invoked, either using subclass methods or CODE
41       references in parameters:
42
43   on_expire
44       Invoked when the timer expires.
45

PARAMETERS

47       The following named parameters may be passed to "new" or "configure":
48
49   on_expire => CODE
50       CODE reference for the "on_expire" event.
51
52   time => NUM
53       The epoch time at which the timer will expire.
54
55       Once constructed, the timer object will need to be added to the "Loop"
56       before it will work.
57
58       Unlike other timers, it does not make sense to "start" this object,
59       because its expiry time is absolute, and not relative to the time it is
60       started.
61

AUTHOR

63       Paul Evans <leonerd@leonerd.org.uk>
64
65
66
67perl v5.30.0                      2019-07-26     IO::Async::Timer::Absolute(3)
Impressum