line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::IPC; |
2
|
21
|
|
|
21
|
|
7710
|
use strict; |
|
21
|
|
|
|
|
18
|
|
|
21
|
|
|
|
|
448
|
|
3
|
21
|
|
|
21
|
|
58
|
use warnings; |
|
21
|
|
|
|
|
18
|
|
|
21
|
|
|
|
|
580
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000044'; |
6
|
|
|
|
|
|
|
|
7
|
21
|
|
|
21
|
|
7451
|
use Test2::API::Instance; |
|
21
|
|
|
|
|
30
|
|
|
21
|
|
|
|
|
69
|
|
8
|
21
|
|
|
21
|
|
90
|
use Test2::Util qw/get_tid/; |
|
21
|
|
|
|
|
21
|
|
|
21
|
|
|
|
|
899
|
|
9
|
21
|
|
|
|
|
122
|
use Test2::API qw{ |
10
|
|
|
|
|
|
|
test2_init_done |
11
|
|
|
|
|
|
|
test2_ipc |
12
|
|
|
|
|
|
|
test2_ipc_enable_polling |
13
|
|
|
|
|
|
|
test2_pid |
14
|
|
|
|
|
|
|
test2_stack |
15
|
|
|
|
|
|
|
test2_tid |
16
|
21
|
|
|
21
|
|
8530
|
}; |
|
21
|
|
|
|
|
35
|
|
17
|
|
|
|
|
|
|
|
18
|
21
|
|
|
21
|
|
100
|
use Carp qw/confess/; |
|
21
|
|
|
|
|
16
|
|
|
21
|
|
|
|
|
969
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @EXPORT_OK = qw/cull/; |
21
|
21
|
|
|
21
|
|
73
|
use base 'Exporter'; |
|
21
|
|
|
|
|
20
|
|
|
21
|
|
|
|
|
6285
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub import { |
24
|
21
|
50
|
|
21
|
|
119
|
goto &Exporter::import unless test2_init_done(); |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
confess "Cannot add IPC in a child process" if test2_pid() != $$; |
27
|
0
|
0
|
|
|
|
|
confess "Cannot add IPC in a child thread" if test2_tid() != get_tid(); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
Test2::API::_set_ipc(_make_ipc()); |
30
|
0
|
|
|
|
|
|
apply_ipc(test2_stack()); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
goto &Exporter::import; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _make_ipc { |
36
|
|
|
|
|
|
|
# Find a driver |
37
|
0
|
|
|
0
|
|
|
my ($driver) = Test2::API::test2_ipc_drivers(); |
38
|
0
|
0
|
|
|
|
|
unless ($driver) { |
39
|
0
|
|
|
|
|
|
require Test2::IPC::Driver::Files; |
40
|
0
|
|
|
|
|
|
$driver = 'Test2::IPC::Driver::Files'; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $driver->new(); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub apply_ipc { |
47
|
0
|
|
|
0
|
0
|
|
my $stack = shift; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my ($root) = @$stack; |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
return unless $root; |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
confess "Cannot add IPC in a child process" if $root->pid != $$; |
54
|
0
|
0
|
|
|
|
|
confess "Cannot add IPC in a child thread" if $root->tid != get_tid(); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
0
|
|
|
|
my $ipc = $root->ipc || test2_ipc() || _make_ipc(); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Add the IPC to all hubs |
59
|
0
|
|
|
|
|
|
for my $hub (@$stack) { |
60
|
0
|
|
|
|
|
|
my $has = $hub->ipc; |
61
|
0
|
0
|
0
|
|
|
|
confess "IPC Mismatch!" if $has && $has != $ipc; |
62
|
0
|
0
|
|
|
|
|
next if $has; |
63
|
0
|
|
|
|
|
|
$hub->set_ipc($ipc); |
64
|
0
|
|
|
|
|
|
$ipc->add_hub($hub->hid); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
test2_ipc_enable_polling(); |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $ipc; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub cull { |
73
|
0
|
|
|
0
|
1
|
|
my $ctx = context(); |
74
|
0
|
|
|
|
|
|
$ctx->hub->cull; |
75
|
0
|
|
|
|
|
|
$ctx->release; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |