| 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.
|