From: Malcolm Beattie Date: Thu, 2 Oct 1997 17:23:48 +0000 (+0000) Subject: Added Thread/queue.t. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=19be36bae59f1ca46824121c1e5628272d472e99;p=p5sagit%2Fp5-mst-13.2.git Added Thread/queue.t. p4raw-id: //depot/perlext/Thread@99 --- diff --git a/queue.t b/queue.t new file mode 100644 index 0000000..c87dcee --- /dev/null +++ b/queue.t @@ -0,0 +1,22 @@ +use Thread; +use Thread::Queue; + +$q = new Thread::Queue; + +sub reader { + my $i; + for ($i = 1; $i <= 10; $i++) { + print "reader: waiting for element $i...\n"; + my $el = $q->dequeue; + print "reader: dequeued element $i: value $el\n"; + } +} + +new Thread \&reader; +my $i; +for ($i = 1; $i <= 10; $i++) { + my $el = int(rand(100)); + select(undef, undef, undef, rand(2)); + print "writer: enqueuing value $el\n"; + $q->enqueue($el); +}