For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > December 2007 > Threads/Queue Help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Threads/Queue Help
Nihilism Machine

2007-12-16, 7:03 pm

I am trying to execute a subroutine which acceses database and other
things online. Instead of waiting for each response, i want to create
a queue of the sub being called 500 times, as subs finish, new ones
are added to always keep it at 500 items in the queue being executed
at the same time. here is what i have so far.

#!/usr/local/bin/perl


# Packages Needed
use threads;
use Thread::Queue;


sub doThisLotsofTimes {
# Do something here
}


for my $i (1 .. 500) {
$stream->enqueue($i);
}

$stream->enqueue(undef);
$kid = new threads(\&check_num, $downstream, $num);
$kid->join;
$downstream->enqueue(undef) if $kid;


# EOF-

if someone could help me out that would be great!

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com