Re: Perl threads in Object Oriented code




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

.



Relevant Pages

  • 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)
  • 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)