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

Calling a object method in a create()

Thread Next
From:
Valter Douglas =?utf-8?q?Lisb=C3=B4a?= Jr.
Date:
July 14, 2008 07:22
Subject:
Calling a object method in a create()
Message ID:
200807141122.26426.douglas@trenix.com.br
Hi all,

I new on threads, but not so on perl.

I trying to execute a thread inside a object method of a class that I make to 
consult SNMP quests and feed a rrddatabase.

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"!

I try to put a \& before $self-> and take another error:
Not a code reference

Are there a way to call a class $self->method in a thread? I search across 
Google and not find any clue.

Thanks in advance.

-- 
Valter Douglas Lisbôa Jr.
Sócio-Diretor
Trenix - IT Solutions
"Nossas Idéias, suas Soluções!"
www.trenix.com.br
contato@trenix.com.br
Tel. +55 19 3402.2957
Cel. +55 19 9183.4244

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