I have a function that works very slowly. I need to enter this function in the main part of the program. So I would like to do something similar to the UNIX yes command, which produces as much input as it reads, but only a little more than necessary. Unlike yes I don't need the values ββfrom STDIN, but I want the values ββin the Perl queue.
In other words: this problem does not lie in the selection of file descriptors, but in the queues supported by the threads.
I assume that the meta code will look something like this:
my $DataQueue = Thread::Queue->new(); my @producers; my $no_of_threads = 10; for (1..$no_of_threads) { push @producers, threads->create(\&producer); } for(<>) {
But is there a more elegant way to do this? I especially don't know how to effectively do wait_until .
source share