develooper Front page | perl.perl5.porters | Postings from February 2009

wonky example in perlthrtut

Thread Next
From:
alex.davies
Date:
February 19, 2009 15:50
Subject:
wonky example in perlthrtut
Message ID:
F00A81D78228413FBED223C3919BE75B@Amelie
Evening all,

In perlthrtut.pod, at line ~850 there is an example called
"prime-pthread". This has been broken at some point by a cleanup.
I think all it needs to patch it is:

-    16 threads->create(\&check_num, $stream, 2);
+    16 my $kid = threads->create(\&check_num, $stream, 2);


However, with this change it now works for the first 600 or so
primes no problem, but then begins to issue "Scalar leaked: 1"
warnings while continuing to print the correct prime numbers!

By adding a C<die unless defined $kid> after the thread creation
results in it stopping with "Thread 117 terminated abnormally: Died".
So it's hitting a limit on the number of threads possible.
(fwiw - this is on Win32).

I'll leave it to someone with more thread-foo to untangle this :-)


Cheers, alex.



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About