我有以下类/包:
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 方法,但该进程确实处理从未被调用过。我在这里想念什么? 线程::池::简单
谢谢,