Re: Perl threads in Object Oriented code
- From: xhoster@xxxxxxxxx
- Date: 30 Apr 2007 20:10:17 GMT
Eric <ecarlson@xxxxxxxxxx> wrote:
Note the following line of code in the former (non OO) script:
my $thr = threads->new(\&get);
This line is calling the 'get' sub. So, if I were to use the OO
scripts shown, how should I implement this?
I tried doing the obvious, which was to change the line to:
my $thr = threads->new($clock->get());
But I got the following error:
thread failed to start: Undefined subroutine &main::1177952602 called
at ./CC.pl line 19.
I doubt you will get the performance you think you will out of this
strategy. Starting a new thread for each task is generally a losing
proposition in Perl. Anyway, try:
my $thr = threads->new(sub{$clock->get()});
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.
- Follow-Ups:
- Re: Perl threads in Object Oriented code
- From: Eric
- Re: Perl threads in Object Oriented code
- References:
- Perl threads in Object Oriented code
- From: Eric
- Perl threads in Object Oriented code
- Prev by Date: Re: hello world with perl
- Next by Date: Re: Perl threads in Object Oriented code
- Previous by thread: Re: Perl threads in Object Oriented code
- Next by thread: Re: Perl threads in Object Oriented code
- Index(es):
Relevant Pages
|