6 if (! $Config{'useithreads'}) {
7 print("1..0 # SKIP Perl not compiled with 'useithreads'\n");
16 require 't/test.pl'; # Test::More work-alike for Perl 5.8.0
23 ### ->dequeue_timed(TIMEOUT, COUNT) test ###
25 my $q = Thread::Queue->new();
28 my @items = qw/foo bar baz qux exit/;
30 is($q->pending(), scalar(@items), 'Queue count');
33 is($q->pending(), scalar(@items), 'Queue count in thread');
34 while (my @el = $q->dequeue_timed(2.5, 2)) {
35 is($el[0], shift(@items), "Thread got $el[0]");
36 if ($el[0] eq 'exit') {
37 is(scalar(@el), 1, 'Thread to exit');
39 is($el[1], shift(@items), "Thread got $el[1]");
42 is($q->pending(), 0, 'Empty queue');
46 is($q->pending(), 1, 'Queue count after thread');
47 is($q->dequeue(), 'done', 'Thread reported done');
48 is($q->pending(), 0, 'Empty queue');
50 ### ->dequeue_timed(TIMEOUT) test on empty queue ###
53 is($q->pending(), 0, 'Empty queue in thread');
54 my @el = $q->dequeue_timed(1.5);
55 is($el[0], undef, "Thread got no items");
56 is($q->pending(), 0, 'Empty queue in thread');
60 is($q->pending(), 1, 'Queue count after thread');
61 is($q->dequeue(), 'done', 'Thread reported done');
62 is($q->pending(), 0, 'Empty queue');