line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Danga::Socket::Callback; |
2
|
1
|
|
|
1
|
|
24114
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
6
|
use base qw(Danga::Socket); |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
999
|
|
5
|
1
|
|
|
1
|
|
48158
|
use fields qw(on_read_ready on_write_ready on_error on_signal_hup context); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.013'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new |
10
|
|
|
|
|
|
|
{ |
11
|
0
|
|
|
0
|
1
|
|
my Danga::Socket::Callback $self = shift; |
12
|
0
|
|
|
|
|
|
my %args = @_; |
13
|
0
|
0
|
|
|
|
|
$self = fields::new($self) unless ref $self; |
14
|
0
|
|
|
|
|
|
$self->SUPER::new($args{handle}); |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
foreach my $field (qw(on_read_ready on_write_ready on_error on_signal_hup context)) { |
17
|
0
|
0
|
|
|
|
|
$self->{$field} = $args{$field} if $args{$field} |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
if ($self->{on_read_ready}) { |
21
|
0
|
|
|
|
|
|
$self->watch_read(1); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
if ($self->{on_write_ready}) { |
25
|
0
|
|
|
|
|
|
$self->watch_write(1); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub event_read |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
0
|
1
|
|
my Danga::Socket::Callback $self = shift; |
34
|
0
|
0
|
|
|
|
|
if (my $code = $self->{on_read_ready}) { |
35
|
0
|
|
|
|
|
|
return $code->($self); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub event_write |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
0
|
1
|
|
my Danga::Socket::Callback $self = shift; |
42
|
0
|
0
|
|
|
|
|
if (my $code = $self->{on_write_ready}) { |
43
|
0
|
|
|
|
|
|
return $code->($self); |
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
|
$self->SUPER::event_write(); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub event_hup |
50
|
|
|
|
|
|
|
{ |
51
|
0
|
|
|
0
|
1
|
|
my Danga::Socket::Callback $self = shift; |
52
|
0
|
0
|
|
|
|
|
if (my $code = $self->{on_signal_hup}) { |
53
|
0
|
|
|
|
|
|
return $code->($self); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub event_err |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
0
|
1
|
|
my Danga::Socket::Callback $self = shift; |
60
|
0
|
0
|
|
|
|
|
if (my $code = $self->{on_error}) { |
61
|
0
|
|
|
|
|
|
$code->($self); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |