Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Can't instantiate Thread::Pool

by alain_desilets (Beadle)
on Sep 20, 2011 at 14:52 UTC ( #926961=perlquestion: print w/ replies, xml ) Need Help??
alain_desilets has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to use Thread::Pool, and I am not even able to instantiate it! Here's the code:
use Thread::Pool; my $pool = Thread::Pool->new(Min => 5, Max => 10);
which is essentially the first two lines of the Synopsis for the module in the doc:

http://search.cpan.org/~micb/ThreadPool-0.1/Pool.pm

When I run the code, I get error message:

Can't bless non-reference value at C:/Perl/site/lib/Thread/Pool.pm (loaded on demand from offset 2009 for 3872 bytes) line 90.

What am I doing wrong?

Thx

Comment on Can't instantiate Thread::Pool
Download Code
Re: Can't instantiate Thread::Pool
by Corion (Pope) on Sep 20, 2011 at 15:01 UTC

    The two lines you quoted are not "essentially the first two lines" of the synopsis. Looking at Thread::Pool, the first three lines are:

    use Thread::Pool; $pool = Thread::Pool->new( {

    So, likely ->new() takes a hashref instead of a list as arguments.

      Oh, I see. I was looking at the documentation for version 0.1:

      http://search.cpan.org/~micb/ThreadPool-0.1/Pool.pm#SYNOPSIS

      which was the first hit that came on Google. I now see that I should be using the doc for version 0.3:

      http://search.cpan.org/~elizabeth/Thread-Pool-0.33/lib/Thread/Pool.pm#SYNOPSIS

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://926961]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2015-07-07 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls