CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Multi threads

 



miniCruzer
Novice

Nov 28, 2010, 12:23 PM

Post #1 of 1 (382 views)
Multi threads Can't Post

I'm playing around with threads, and I can't get them to behave like I want them to.

Here's the old code:

Code
# snip 
$commands{lc($parv[0])}{code}->($target->[0], $nick, $args) if $args;
$commands{lc($parv[0])}{code}->($target->[0], $nick) if !$args;
# snip


New Code:

Code
# snip  
my $thread = threads->create(sub {
$commands{lc($parv[0])}{code}->($target->[0], $nick, $args) if $args;
$commands{lc($parv[0])}{code}->($target->[0], $nick) if !$args;
});
my @void = $thread->join();
$thread->kill('SIGUSR1');
threads->exit;
# snip


Yes, threads are installed. Any idea why this fails? It gives me a completely obscure error that really has nothing to do with the threads at all, but the code is functional unthreaded.

Error:

(in cleanup) Where's _elem?!!? at /usr/local/lib/perl5/site_perl/5.12.2/LWP/UserAgent/Determined.pm line 9 during global destruction.
Compilation failed in require at /usr/local/lib/perl5/site_perl/5.12.2/WWW/CPAN.pm line 19 during global destruction.


If you're interested, https://github.com/miniCruzer/Aspire/blob/poe/bin/aspire is the file being edited, down at lines 184 and 185. Code with threads have not been pushed.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives