develooper Front page | perl.ithreads | Postings from July 2008

Re: Thread::pool

Thread Previous | Thread Next
From:
Javier
Date:
July 30, 2008 01:11
Subject:
Re: Thread::pool
Message ID:
602eb19e0807300111w71770793m4d327327220bed56@mail.gmail.com
Hi!,

I understand that, to initialize the $pool ideally between daemon()
and scan_files(), just after the fork.
The code:
....
daemon();
$pool = Thread::Pool->new(
  {
    optimize => 'memory',
    do => \&check_system,
    pre => sub {shift; print "starting a new work with\n" },
    post => sub { print "stopping the work\n" },
    frequency => 10,
    autoshutdown => 1,
    workers => 20,
    maxjobs => 100,
    minjobs => 10,
  }
);
scan_files();

And the daemon() function implement the fork.

Well, so the program does not work.
The program execute, but does nothing. It was stopped without doing
anything. Just run once while(1) of scan_files().
I think that is how should the $pool did not exist.

2008/7/29 Jerry D. Hedden <jdhedden@cpan.org>:
>> First i initialice the pool and then i set the process as a daemon. Then i
>> call the scan_files() function.
>
> Nope.  That's no good.
>
>> I also test to initialice the pool inside the daemon() function
>
> Depends on where in daemon you do it - it must come after the fork.
>
>> and between daemon() and scan_files().
>
> Better.
>
>> Doing that, the output is blank, but it doesn't work.
>
> Define "doesn't work".
>



-- 
A greeting,

Javier.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About