MCE
view release on metacpan or search on metacpan
t/04_channel_threadsfast_mp.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
BEGIN {
plan skip_all => "Not used on Cygwin" if ( $^O eq 'cygwin' );
if ( $] lt '5.010001' && $^O ne 'MSWin32' ) {
plan skip_all => "old Perl and threads not supported on Unix platforms";
}
eval 'use threads'; ## no critic
plan skip_all => "threads not available" if $@;
use_ok 'MCE::Channel';
use_ok 'MCE::Channel::ThreadsFast';
}
my $chnl = MCE::Channel->new( impl => 'ThreadsFast', mp => 1 );
is $chnl->impl(), 'ThreadsFast', 'implementation name';
# send recv
{
$chnl->send('a string');
is $chnl->recv, 'a string', 'send recv scalar';
$chnl->send('');
is $chnl->recv, '', 'send recv blank string';
$chnl->send(undef);
is $chnl->recv, '', 'send recv undef stringified';
}
# send recv_nb
if ($^O ne 'MSWin32')
{
$chnl->send('a string');
is $chnl->recv_nb, 'a string', 'send recv_nb scalar';
$chnl->send('');
is $chnl->recv_nb, '', 'send recv_nb blank string';
$chnl->send(undef);
is $chnl->recv_nb, '', 'send recv_nb undef stringified';
}
# send2 recv2
{
$chnl->send2('a string');
is $chnl->recv2, 'a string', 'send2 recv2 scalar';
$chnl->send2('');
is $chnl->recv2, '', 'send2 recv2 blank string';
$chnl->send2(undef);
is $chnl->recv2, '', 'send2 recv2 undef stringified';
}
# send2 recv2_nb
if ($^O ne 'MSWin32')
{
$chnl->send2('a string');
is $chnl->recv2_nb, 'a string', 'send2 recv2_nb scalar';
$chnl->send2('');
is $chnl->recv2_nb, '', 'send2 recv2_nb blank string';
$chnl->send2(undef);
is $chnl->recv2_nb, '', 'send2 recv2_nb undef stringified';
( run in 0.845 second using v1.01-cache-2.11-cpan-5e09290becf )