line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Message::Passing::Filter::Delay; |
2
|
2
|
|
|
2
|
|
1739
|
use Moo; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
22
|
|
3
|
2
|
|
|
2
|
|
892
|
use MooX::Types::MooseLike::Base qw( :all ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1005
|
|
4
|
2
|
|
|
2
|
|
1569
|
use AnyEvent; |
|
2
|
|
|
|
|
7870
|
|
|
2
|
|
|
|
|
84
|
|
5
|
2
|
|
|
2
|
|
19
|
use Scalar::Util qw/ weaken /; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
176
|
|
6
|
2
|
|
|
2
|
|
12
|
use namespace::clean -except => 'meta'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with qw/ |
9
|
|
|
|
|
|
|
Message::Passing::Role::Input |
10
|
|
|
|
|
|
|
Message::Passing::Role::Output |
11
|
|
|
|
|
|
|
/; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has delay_for => ( |
14
|
|
|
|
|
|
|
isa => Num, |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
required => 1, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub consume { |
20
|
1
|
|
|
1
|
1
|
379
|
my ($self, $message) = @_; |
21
|
1
|
|
|
|
|
5
|
weaken($self); |
22
|
1
|
|
|
|
|
2
|
my $t; $t = AnyEvent->timer( |
23
|
|
|
|
|
|
|
after => $self->delay_for, |
24
|
|
|
|
|
|
|
cb => sub { |
25
|
1
|
|
|
1
|
|
96983
|
undef $t; |
26
|
1
|
|
|
|
|
109
|
$self->output_to->consume($message); |
27
|
|
|
|
|
|
|
}, |
28
|
1
|
|
|
|
|
69
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Message::Passing::Filter::Delay - Delay messages for some time. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DESCRIPTION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
This filter passes all incoming messages through with no changes, however |
41
|
|
|
|
|
|
|
not immediately - they are delayed . |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
You would normally never want to use this, but it can be useful for |
44
|
|
|
|
|
|
|
testing occasionally, or avoiding race conditions. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 delay_for |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Floating point number, indicating how many seconds to delay messages for. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 consume ($msg) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Sets up a timed callback in the event loop, which passes the message |
57
|
|
|
|
|
|
|
to the output (and deletes itself) once the timeout has expired |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SPONSORSHIP |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This module exists due to the wonderful people at Suretec Systems Ltd. |
62
|
|
|
|
|
|
|
who sponsored its development for its |
63
|
|
|
|
|
|
|
VoIP division called SureVoIP for use with |
64
|
|
|
|
|
|
|
the SureVoIP API - |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
See L. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |