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