Thread::Pool is a very, very complicated, over-engineered way of doing something very simple.

If you are having problems with threads, using Thread::Pool won't make those problems go away.

What it will do is exacerbate any and every small problem you encounter, and turn it into a complete nightmare to try and track down and debug.

This is a complete working example of a thread pool:

#! perl -slw use strict; use threads; use Thread::Queue; ## The worker sub sub worker { my $tid = threads->tid; my $Q = shift; while( my $workitem = $Q->dequeue ) { print "$tid: processing $workitem"; sleep $workitem; } } ### How many in the pool our $T //= 4; ### The queue my $Q = new Thread::Queue; ### Start the pool my @workers = map threads->create( \&worker, $Q ), 1 .. $T; ### Give'm some stuff to do $Q->enqueue( map int( rand 10 ), 1 .. 100 ); ### Do some other stuff here while they do their thing. ### Tell'm they're done $Q->enqueue( (undef) x $T ); ### Wait for'm to finish up $_->join for @workers; ### finished.

Now, go look inside Thread::Pool. Then Thread::Conveyor; Then Thread::Conveyor::Monitored. Then Thread::Tie. The Thread::Tie::Thread....I got bored looking at this point. Now imagine what happens when something goes wrong?

Using that lot is an absurd response to a problem with leakage. It won't fix the leaks. It will exacerbate them and make them much, much harder to track and deal with.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^10: perl 5.12.3 + threads + memory leak by BrowserUk
in thread perl 5.12.3 + threads + memory leak by kamenpetrov

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.