Re: Perl threads in Object Oriented code
- From: Eric <ecarlson@xxxxxxxxxx>
- Date: 30 Apr 2007 14:15:38 -0700
xhoster@xxxxxxxxx wrote:
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
Someone made a similar suggestion, but it seems as if you are
redefining the sub in the file in which it is being called instead of
using it from it's current module(?). Am I missing something here?
Eric
.
- References:
- Perl threads in Object Oriented code
- From: Eric
- Re: Perl threads in Object Oriented code
- From: xhoster
- Perl threads in Object Oriented code
- Prev by Date: Re: Perl threads in Object Oriented code
- Previous by thread: Re: Perl threads in Object Oriented code
- Next by thread: Re: hello world with perl
- Index(es):
Relevant Pages
|
|