Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 104 lines (69 sloc) 1.741 kB
ce7ee1a @rcaputo Add wakeup timers (alarms) and fix some bugs in the other timers.
authored
1 package Reflex::Wakeup;
5b0127b @rcaputo Remove emit() from roles.
authored
2 # vim: ts=2 sw=2 noexpandtab
ce7ee1a @rcaputo Add wakeup timers (alarms) and fix some bugs in the other timers.
authored
3
4 use Moose;
5 extends 'Reflex::Base';
5b0127b @rcaputo Remove emit() from roles.
authored
6 use Reflex::Callbacks qw(make_emitter);
ce7ee1a @rcaputo Add wakeup timers (alarms) and fix some bugs in the other timers.
authored
7
18993bf @rcaputo The extra "name" parameters weren't needed. Begin documenting the new…
authored
8 has when => ( isa => 'Num', is => 'rw' );
ce7ee1a @rcaputo Add wakeup timers (alarms) and fix some bugs in the other timers.
authored
9
10 with 'Reflex::Role::Wakeup' => {
5b0127b @rcaputo Remove emit() from roles.
authored
11 att_when => "when",
12 cb_wakeup => make_emitter(on_time => "time"),
ce7ee1a @rcaputo Add wakeup timers (alarms) and fix some bugs in the other timers.
authored
13 method_stop => "stop",
14 method_reset => "reset",
15 };
16
5bc7069 @rcaputo Make classes immutable. Mutable classes are a lot slower.
authored
17 __PACKAGE__->meta->make_immutable;
18
ce7ee1a @rcaputo Add wakeup timers (alarms) and fix some bugs in the other timers.
authored
19 1;
122cbcc @rcaputo Document! Oh, gods, it burns!
authored
20
21 __END__
22
23 =head1 NAME
24
25 Reflex::Wakeup - A stand-alone single-shot callback at an absolute time
26
27 =head1 SYNOPSIS
28
29 #!/usr/bin/env perl
30
31 use warnings;
32 use strict;
33
34 use Reflex::Wakeup;
35
36 my @wakeups;
37 my $ding = 0;
38
39 for my $delay (1..5) {
40 push @wakeups, Reflex::Wakeup->new(
41 when => time() + $delay,
42 on_time => sub {
43 print "got wakeup $delay\n";
44 @wakeups = () if ++$ding >= @wakeups;
45 },
46 );
47 }
48
49 Reflex->run_all();
50 exit;
51
52 =head1 DESCRIPTION
53
54 Reflex::Wakeup invokes a callback at a specific absolute UNIX epoch
55 time. Wakeup timers may be stopped and reset.
56
57 =head2 Public Attributes
58
59 =head3 when
60
61 Implemented and documented by L<Reflex::Role::Wakeup/when>.
62
63 =head2 Public Callbacks
64
65 =head3 on_time
66
67 Implemented and documented by L<Reflex::Role::Wakeup/cb_wakeup>.
68
69 =head2 Public Methods
70
71 =head3 reset
72
73 Implemented and documented by L<Reflex::Role::Wakeup/method_reset>.
74
75 =head3 stop
76
77 Implemented and documented by L<Reflex::Role::Interval/method_stop>.
78
79 =head1 EXAMPLES
80
81 TODO - Many. Link to them.
82
83 =head1 SEE ALSO
84
85 L<Reflex>
86 L<Reflex::Role>
87 L<Reflex::Role::Interval>
88 L<Reflex::Role::Timeout>
89 L<Reflex::Role::Wakeup>
90 L<Reflex::Interval>
91 L<Reflex::Timeout>
92
93 L<Reflex/ACKNOWLEDGEMENTS>
94 L<Reflex/ASSISTANCE>
95 L<Reflex/AUTHORS>
96 L<Reflex/BUGS>
97 L<Reflex/BUGS>
98 L<Reflex/CONTRIBUTORS>
99 L<Reflex/COPYRIGHT>
100 L<Reflex/LICENSE>
101 L<Reflex/TODO>
102
103 =cut
Something went wrong with that request. Please try again.