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

Re: Calling a object method in a create()

Thread Previous | Thread Next
From:
Jerry D. Hedden
Date:
July 14, 2008 08:41
Subject:
Re: Calling a object method in a create()
Message ID:
1ff86f510807140841r7bc607a7m1041e7bde78cf51f@mail.gmail.com
Valter Douglas LisbĂ´a Jr. wrote:
> The code bellow functions very nice.
>
> ---------------------
> while(my ($id, $ep, $local, $tolerance, $lasterr, $hostscount) =
> $sthLocals->fetchrow_array()) {
>  $self->localPolling($id, $ep, $local, $tolerance, $lasterr, $hostscount);
> }
> ---------------------
>
> But if I try to execute with a thread:
>
> ---------------------
> while(my ($id, $ep, $local, $tolerance, $lasterr, $hostscount) =
> $sthLocals->fetchrow_array()) {
>  my $thr = threads->create($self->localPooling, $id, $ep, $local, $tolerance,
> $lasterr, $hostscount);
> }
> ---------------------
>
> It returns a error:
> Can't locate object method "localPooling" via package "Poller::Check"!

Try

while (my ($id, $ep, $local, $tolerance, $lasterr, $hostscount)
            = $sthLocals->fetchrow_array())
{
    my $thr = threads->create(sub {
        $self->localPooling($id, $ep, $local, $tolerance, $lasterr,
$hostscount);
    });
}

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