line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wx::Perl::Thread::Listener; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2415
|
use Wx; # before 'use base' |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use strict; |
6
|
|
|
|
|
|
|
use warnings; |
7
|
|
|
|
|
|
|
use base qw(Wx::EvtHandler); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use threads::shared; |
10
|
|
|
|
|
|
|
use Wx::Event qw(EVT_COMMAND); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $EVENT_ID : shared; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
my( $class ) = @_; |
16
|
|
|
|
|
|
|
my $self = $class->SUPER::new( ); |
17
|
|
|
|
|
|
|
$self->init; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init { |
23
|
|
|
|
|
|
|
my( $self ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$EVENT_ID ||= Wx::NewEventType(); |
26
|
|
|
|
|
|
|
EVT_COMMAND( $self, -1, $EVENT_ID, |
27
|
|
|
|
|
|
|
sub { |
28
|
|
|
|
|
|
|
my( $self, $event ) = @_; |
29
|
|
|
|
|
|
|
my $data = $event->GetData; |
30
|
|
|
|
|
|
|
$self->_notify_subscribers( $data ); |
31
|
|
|
|
|
|
|
} ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _send_event { |
35
|
|
|
|
|
|
|
my( $self, $value ) = @_; |
36
|
|
|
|
|
|
|
my $e = Wx::PlThreadEvent->new( -1, $EVENT_ID, $value ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Wx::PostEvent( $self, $e ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _notify_subscribers { die 'Override in subclass' } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |