我有以下的類/包:駝鹿和擴大非駝鹿類
package Data::CrawlerThreadPool;
use Moose;
use MooseX::InsideOut;
use MooseX::NonMoose;
extends 'Thread::Pool::Simple';
around BUILDARGS => sub {
my $orig = shift;
my $class = shift;
return $class->$orig(do => [\&_do_handle],
min => 5,
max => 10);
};
sub _do_handle {
$| = 1;
print "In Do handle";
}
1;
在我的主腳本
,我把它(爲如..)是這樣的:
#!/usr/bin/env perl
use strict;
use warnings;
use Data::CrawlerThreadPool;
my $tp = Data::CrawlerThreadPool->new();
my @args = qw(0 0 0 0 0 0 0 0 0);
$tp->add(@args) for (0..10);
$tp->join();
好像BUILDARGS方法被調用,但該進程處理永遠不會被調用。 我在這裏錯過了什麼? Thread::Pool::Simple
感謝,
好吧,你從來不叫'$ TP - > _ do_handle()',所以....你是怎麼想到要發生? – 2012-08-16 17:26:22
它看起來像Thread :: Pool :: Simple有一個相當簡單的API,你可能會更好地創建你的對象來代理調用它創建的TPS對象。 – 2012-08-16 20:12:42