Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl-w #Libs use strict; use threads; use threads::shared; my %thr; #Threads controling each node my %thr_up; share (%thr_up); #if thread finished job $thr_up shuould +be = 0 SMALL:for (1 .. 1000) { #Find a waiting thread unless ($thr_up{"FREE_HOST"}) { $thr_up{"FREE_HOST"} = 1; #thread working flag $thr{"FREE_HOST"} = threads->create("blast_thread"); sleep(1); my @list = threads->list(); $list[scalar(@list-1)]->join () if (scalar(@list) > 2); foreach my $l (@list) {print "$l\n";} } #Just for my surprise: print $thr{FREE_HOST}->tid, ",$thr{FREE_HOST} \n" if ($thr{FREE_HO +ST}->tid); } sub blast_thread { $thr_up{FREE_HOST} = 0; print "Server UP\n"; return; } ############################
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A Memory Leak in Perl iThreads?
by liz (Monsignor) on Mar 21, 2004 at 14:50 UTC | |
by cav (Initiate) on Mar 21, 2004 at 15:13 UTC | |
by liz (Monsignor) on Mar 21, 2004 at 15:31 UTC | |
by cav (Initiate) on Mar 21, 2004 at 16:43 UTC | |
|
Re: A Memory Leak in Perl iThreads?
by BrowserUk (Patriarch) on Mar 21, 2004 at 17:17 UTC | |
by Anonymous Monk on Mar 21, 2004 at 19:28 UTC | |
|
Re: A Memory Leak in Perl iThreads?
by Old_Gray_Bear (Bishop) on Mar 21, 2004 at 13:18 UTC | |
by cav (Initiate) on Mar 21, 2004 at 13:25 UTC | |
|
Re: A Memory Leak in Perl iThreads?
by cormac (Acolyte) on Mar 21, 2004 at 18:57 UTC |