Re: Perl threads in Object Oriented code



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
.



Relevant Pages

  • Re: free source guestbook (finished)
    ... > idiosyncractic indenting aside): ... >> sub dosign ... That means you can have perl do that work for you ... > script if it can be sure that certain files are there. ...
    (comp.lang.perl.misc)
  • Re: Detecting is hyperthreading is enabled with WMI?
    ... It is too bad that WMI does not give this info. ... have to be done to the script. ... Public Sub DisplayProcessorInfo ... dim ProcessorSet, Processor ...
    (microsoft.public.windowsxp.wmi)
  • Cant make this page work
    ... I can't make this script work properly. ... The script at the bottom of the html page ... Does someone have a perl ... sub output_trace_headers { ...
    (comp.lang.javascript)
  • Re: Maybe I should try a different approach
    ... entire time my script is running, then have it close when my script is done and maybe have some dots keep adding to the text message until the script is fully completed? ... ' The "Three Ugly Hack" Script, ... Sub oATO_vbTimerEvent' timer event handler... ... Public Property Let Left ...
    (microsoft.public.scripting.vbscript)
  • Re: Win32_Product doesnt list all installed Applications
    ... 'Must have ADSI and WMI installed on PC running script. ... CONST ForReading = 1 ... Sub Connect ... strHTML = "Smoke'm if you Got'em" ...
    (microsoft.public.windows.server.scripting)