line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::IPC; |
2
|
20
|
|
|
20
|
|
6567
|
use strict; |
|
20
|
|
|
|
|
21
|
|
|
20
|
|
|
|
|
424
|
|
3
|
20
|
|
|
20
|
|
61
|
use warnings; |
|
20
|
|
|
|
|
22
|
|
|
20
|
|
|
|
|
616
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000042'; |
6
|
|
|
|
|
|
|
|
7
|
20
|
|
|
20
|
|
6744
|
use Test2::API::Instance; |
|
20
|
|
|
|
|
31
|
|
|
20
|
|
|
|
|
62
|
|
8
|
20
|
|
|
20
|
|
83
|
use Test2::Util qw/get_tid/; |
|
20
|
|
|
|
|
16
|
|
|
20
|
|
|
|
|
801
|
|
9
|
20
|
|
|
|
|
120
|
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
|
20
|
|
|
20
|
|
7729
|
}; |
|
20
|
|
|
|
|
31
|
|
17
|
|
|
|
|
|
|
|
18
|
20
|
|
|
20
|
|
85
|
use Carp qw/confess/; |
|
20
|
|
|
|
|
19
|
|
|
20
|
|
|
|
|
855
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @EXPORT_OK = qw/cull/; |
21
|
20
|
|
|
20
|
|
60
|
use base 'Exporter'; |
|
20
|
|
|
|
|
20
|
|
|
20
|
|
|
|
|
5454
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub import { |
24
|
20
|
50
|
|
20
|
|
101
|
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__ |