Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: How to Optionally enable threads in Perl 5.10.0

by ikegami (Patriarch)
on Aug 09, 2010 at 18:13 UTC ( [id://853891]=note: print w/replies, xml ) Need Help??


in reply to How to Optionally enable threads in Perl 5.10.0

I don't know what they're talking about.
$ /usr/bin/perl -v This is perl, v5.10.0 built for i486-linux-gnu-thread-multi ... $ perl -e'eval "use threads; async { print qq{ok\n} }->join;"' ok

Maybe it's referring to symbol import? That passage is not present in newer version of Perl.

Mind you, it doesn't really make much sense to load threads conditionally. It seems to me it would make more sense to choose which module to use conditionally, one that uses uses threads, one that doesn't.

my $engine; if ($use_threads) { require Engine::Threaded; $engine = Engine::Threaded->new(); } else { require Engine::Fallback; $engine = Engine::Fallback->new(); }

Replies are listed 'Best First'.
Re^2: How to Optionally enable threads in Perl 5.10.0
by DrWhy (Chaplain) on Aug 09, 2010 at 18:27 UTC
    Yeah, I did the same thing just now:
    C:\Documents and Settings\Mine>c:\Perl5.10\bin\perl.exe -e "eval 'use +threads'; print \"$@\"; $t1 = threads->create(sub {print '1'}); $t2 = + threads->create(sub{print '2'}); $t1->join; $t2->join();" 12 C:\Documents and Settings\Mine>
    Requiring in diff't modules in the case at hand doesn't make much since. I'm only doing thread work in the main script, so the '*threaded' module would just contain the 'use threads' statement and the '*notthreaded' module would be empty (or just wouldn't exist).

    --DrWhy

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://853891]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2026-05-11 21:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.