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; } }
In reply to Re: What is the correct way to use Thread::Queue::Any ?
by fx
in thread What is the correct way to use Thread::Queue::Any ?
by fx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |