Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: What is the correct way to use Thread::Queue::Any ?

by fx (Pilgrim)
on Jan 07, 2004 at 18:13 UTC ( [id://319548] : note . print w/replies, xml ) Need Help??


in reply to What is the correct way to use Thread::Queue::Any ?

Thanks to Molt and to liz - Thread::Conveyor seems to be working with the following piece of code:

#!/opt/perl-5.8.2/bin/perl -w use strict; use threads; use Thread::Conveyor; my $queue = Thread::Conveyor->new; my $prod_thread = new threads(\&producer); my $cons_thread = new threads(\&consumer); $prod_thread->join; $cons_thread->join; sub producer { my $value = 1234; $queue->put( $value ); $queue->put( undef ); } sub consumer { while( my $returned_value = $queue->take ) { printf "I have been returned: %i\n", $returned_value; } }