For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2006 > Objects and Threading









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Objects and Threading
ramblinpeck@gmail.com

2006-01-30, 6:56 pm

New to threads, and really new to the deeper parts of perl, been using
it for years as a all purpose scripting solution, but just now getting
into embedding it and using it for rapid prototyping. Basic outline of
program, I have a controller which will be pretty much the heart of the
program, setting things up, and several classes, one in particular that
we'll call Downloader.

I'm trying to make this multithreaded, so that I can have multiple
downloaders going at once, but Downloader being a class instance is
throwing me off. It may just be syntax, but my googling didn't produce
any examples of doing threading with a class instance.

my $downloader = eval { new Downloader();} or die (@_);

my $thread1 = threads->new($downloader->fetch,
"http://www.webaddress.com", \%siteHash);

$thread1->join;

I've tried putting \& in front of downloader->fetch, as well as putting
it in front of fetch itself, but no luck. Right now its just executing
the fetch function in downloader and generating an error :
thread failed to start: Undefined subroutine
&main::http://www.webaddress.com called

Any help appreciated.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com