Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^2: Controlling Thread Numbers

by BBQ (Curate)
on Oct 19, 2007 at 02:01 UTC ( [id://645879] : note . print w/replies, xml ) Need Help??

in reply to Re: Controlling Thread Numbers
in thread Controlling Thread Numbers

Hey NetWallah,

Thanks for the snippet!

I'm having a hard time following though... on this line:

our $KIDS   = $count > 20? 10 : int ($count / 4) || 1;

Won't $KIDS always be assigned the value 1? Unless $count has already been assigned a value elsewhere... and I'm assuming that the keys in %ServerInfo are IP addresses that get passed to another sub_routine called Ping_it()?

Sorry if I'm being a little dense here. Just trying to get what goes where and there seem to be a few pieces of the puzzle still missing.

Thanks again!

Replies are listed 'Best First'.
Re^3: Controlling Thread Numbers
by NetWallah (Canon) on Oct 21, 2007 at 20:44 UTC
    Sorry - the snippet was indeed incomplete without an explanation of external variables.

    "$count" comes from the number of servers I was processing - Under test conditions, it would be well under 20, and I would do all work in less than 5 sub processes/threads (Only one thread, if $count was less than 5). Under "Normal" conditions, it was in the 200 range, resulting in 10 threads.

    The %serverinfo was a HOH had other info besides IP - Server Name, and related info. I was laid off work on Tuesday 10/16, and no longer have access to the code I wrote, or I would gladly share it.

         "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom