5 our $VERSION = '1.302040';
8 use Test2::API::Instance;
9 use Test2::Util qw/get_tid/;
13 test2_ipc_enable_polling
21 our @EXPORT_OK = qw/cull/;
22 BEGIN { require Exporter; our @ISA = qw(Exporter) }
25 goto &Exporter::import unless test2_init_done();
27 confess "Cannot add IPC in a child process (" . test2_pid() . " vs $$)" if test2_pid() != $$;
28 confess "Cannot add IPC in a child thread (" . test2_tid() . " vs " . get_tid() . ")" if test2_tid() != get_tid();
30 Test2::API::_set_ipc(_make_ipc());
31 apply_ipc(test2_stack());
33 goto &Exporter::import;
38 my ($driver) = Test2::API::test2_ipc_drivers();
40 require Test2::IPC::Driver::Files;
41 $driver = 'Test2::IPC::Driver::Files';
44 return $driver->new();
54 confess "Cannot add IPC in a child process" if $root->pid != $$;
55 confess "Cannot add IPC in a child thread" if $root->tid != get_tid();
57 my $ipc = $root->ipc || test2_ipc() || _make_ipc();
59 # Add the IPC to all hubs
60 for my $hub (@$stack) {
62 confess "IPC Mismatch!" if $has && $has != $ipc;
65 $ipc->add_hub($hub->hid);
68 test2_ipc_enable_polling();
89 Test2::IPC - Turn on IPC for threading or forking support.
93 You should C<use Test2::IPC;> as early as possible in your test file. If you
94 import this module after API initialization it will attempt to retrofit IPC
95 onto the existing hubs.
99 All exports are optional.
105 Cull allows you to collect results from other processes or threads on demand.
111 The source code repository for Test2 can be found at
112 F<http://github.com/Test-More/test-more/>.
118 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
126 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
132 Copyright 2016 Chad Granum E<lt>exodist@cpan.orgE<gt>.
134 This program is free software; you can redistribute it and/or
135 modify it under the same terms as Perl itself.
137 See F<http://dev.perl.org/licenses/>