Skip to content

Commit

Permalink
Thread-Suspend v1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhedden committed Apr 21, 2016
1 parent 9848154 commit d19eb3f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Revision history for Perl extension Thread::Suspend.

1.16 Wed Feb 27 17:43:15 2008
- More fixes to tests

1.15 Wed Feb 27 13:43:14 2008
- More fixes to tests

Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Thread::Suspend version 1.15
Thread::Suspend version 1.16
============================

This module adds suspend and resume operations for threads.
Expand Down
6 changes: 3 additions & 3 deletions lib/Thread/Suspend.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Thread::Suspend; {
use strict;
use warnings;

our $VERSION = '1.15';
our $VERSION = '1.16';

use threads 1.39;
use threads::shared 1.01;
Expand Down Expand Up @@ -155,7 +155,7 @@ Thread::Suspend - Suspend and resume operations for threads
=head1 VERSION
This document describes Thread::Suspend version 1.15
This document describes Thread::Suspend version 1.16
=head1 SYNOPSIS
Expand Down Expand Up @@ -316,7 +316,7 @@ Thread::Suspend Discussion Forum on CPAN:
L<http://www.cpanforum.com/dist/Thread-Suspend>
Annotated POD for Thread::Suspend:
L<http://annocpan.org/~JDHEDDEN/Thread-Suspend-1.15/lib/Thread/Suspend.pm>
L<http://annocpan.org/~JDHEDDEN/Thread-Suspend-1.16/lib/Thread/Suspend.pm>
Source repository:
L<http://code.google.com/p/thread-suspend/>
Expand Down
2 changes: 1 addition & 1 deletion t/01_self.t
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sub counter2
my $tid = threads->tid();
threads->self()->suspend();
while (1) {
delete($::COUNTS[$tid]);
delete($::COUNTS{$tid});
threads->yield();
}
}
Expand Down
34 changes: 24 additions & 10 deletions t/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,48 @@
};


our @COUNTS :shared;
our %COUNTS :shared;

sub counter
{
my $tid = threads->tid();
while (1) {
delete($COUNTS[$tid]);
delete($COUNTS{$tid});
threads->yield();
}
}


sub pause
{
threads->yield() for (1..$::nthreads);
threads->yield() for (0..$::nthreads);
select(undef, undef, undef, shift);
threads->yield() for (1..$::nthreads);
threads->yield() for (0..$::nthreads);
}

sub check {
my ($thr, $running, $line) = @_;
my $tid = $thr->tid();
pause(0.1);
$COUNTS[$tid] = 1;
pause(0.1);
ok(($running eq 'running') ? ! exists($COUNTS[$tid])
: exists($COUNTS[$tid]),
"Thread $tid $running (see line $line)");

delete($COUNTS{$tid});
if (exists($COUNTS{$tid})) {
ok(0, "BUG: \$COUNTS{$tid} not deleted");
}
$COUNTS{$tid} = $tid;

if ($running eq 'running') {
for (1..100) {
pause(0.1);
last if (! exists($COUNTS{$tid}));
}
ok(! exists($COUNTS{$tid}), "Thread $tid $running (see line $line)");
} else {
for (1..3) {
pause(0.1);
last if (! exists($COUNTS{$tid}));
}
ok(exists($COUNTS{$tid}), "Thread $tid $running (see line $line)");
}
}


Expand Down

0 comments on commit d19eb3f

Please sign in to comment.