6 require Config; import Config;
7 unless ($Config{'useithreads'}) {
8 print "1..0 # Skip: no ithreads\n";
17 my $q = new Thread::Queue;
21 my $test : shared = 1;
30 my $tid = threads->self->tid;
34 # print "reader (tid $tid): waiting for element $i...\n";
37 # print "ok $test\n"; $test++;
38 # print "reader (tid $tid): dequeued element $i: value $el\n";
39 select(undef, undef, undef, rand(1));
42 # print "reader (tid $tid) returning\n";
51 for (my $i = 0; $i < $nthreads; $i++) {
52 push @threads, threads->new(\&reader, $i);
55 for (my $i = 1; $i <= 20; $i++) {
56 my $el = int(rand(100));
57 select(undef, undef, undef, rand(1));
58 # print "writer: enqueuing value $el\n";
62 $q->enqueue((-1) x $nthreads); # one end marker for each thread
65 # print "waiting for join\n";