| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package BusyBird::Watcher; |
|
2
|
11
|
|
|
11
|
|
4413
|
use v5.8.0; |
|
|
11
|
|
|
|
|
31
|
|
|
|
11
|
|
|
|
|
449
|
|
|
3
|
11
|
|
|
11
|
|
51
|
use strict; |
|
|
11
|
|
|
|
|
14
|
|
|
|
11
|
|
|
|
|
337
|
|
|
4
|
11
|
|
|
11
|
|
62
|
use warnings; |
|
|
11
|
|
|
|
|
14
|
|
|
|
11
|
|
|
|
|
422
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
1; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=pod |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BusyBird::Watcher - interface for watcher objects |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=for test_synopsis |
|
15
|
|
|
|
|
|
|
my ($timeline); sub callback {} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $watcher = $timeline->watch_unacked_counts( |
|
20
|
|
|
|
|
|
|
assumed => { total => 0 }, |
|
21
|
|
|
|
|
|
|
callback => sub { ... } |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$watcher->active; ## returns true if the $watcher is active |
|
25
|
|
|
|
|
|
|
$watcher->cancel(); ## cancels the $watcher |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This is an interface (or role) class for watcher objects. |
|
30
|
|
|
|
|
|
|
A watcher is something that represents a callback registered somewhere. |
|
31
|
|
|
|
|
|
|
Users can use a watcher to cancel (i.e. unregister) the callback. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
L does not implement any method. |
|
34
|
|
|
|
|
|
|
Implementations of L must be a subclass of L |
|
35
|
|
|
|
|
|
|
and implement the following methods. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 $is_active = $watcher->active() |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns true if the C<$watcher> is active. Returns false otherwise. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
An active watcher is the one whose callback can be called. |
|
44
|
|
|
|
|
|
|
On the other hand, the callback of an inactive watcher will never be called. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 $watcher->cancel() |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Cancels the C<$watcher>, that is, makes it inactive. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
If C<$watcher> is already inactive, it stays inactive. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 AUTHOR |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Toshio Ito C<< >> |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|