Under very tight concurrency it is possible that the test will not be given
sufficient timeshare before the scheduled 'point in the future', which would
result in us asking Time::HiRes to sleep for a negative amount of time, which
it "helpfully" converts to an obnoxious exception.
use Test::More;
use Test::Exception;
use Time::HiRes qw(time sleep);
+use List::Util 'max';
use DBICTest;
$pid = $$;
- sleep ( $t - time );
+ sleep( max( 0.1, $t - time ) );
note ("Child process $pid starting work at " . time() );
my $work = sub {
use Test::More;
use Test::Exception;
use Time::HiRes qw(time sleep);
+use List::Util 'max';
plan skip_all => 'DBIC does not actively support threads before perl 5.8.5'
if "$]" < 5.008005;
my $newthread = async {
my $tid = threads->tid;
- sleep ($t - time);
+ sleep( max( 0.1, $t - time ) );
# FIXME if we do not stagger the threads, sparks fly due to CXSA
sleep ( $tid / 10 ) if "$]" < 5.012;
use Scalar::Util 'weaken';
use Time::HiRes qw(time sleep);
+use List::Util 'max';
use DBICTest;
my $newthread = async {
my $tid = threads->tid;
- sleep ($t - time);
+ sleep( max( 0.1, $t - time ) );
# FIXME if we do not stagger the threads, sparks fly due to CXSA
sleep ( $tid / 10 ) if "$]" < 5.012;
use Errno ();
use DBIx::Class::_Util 'sigwarn_silencer';
use Time::HiRes qw(time sleep);
+use List::Util 'max';
# README: If you set the env var to a number greater than 5,
# we will use that many children
push @threads, threads->create(sub {
my $tid = threads->tid;
- sleep ($t - time);
+ sleep( max( 0.1, $t - time ) );
note ("Thread $tid starting work at " . time() );
my $rsrc = $schema->source('Artist');