Skip Menu |

This queue is for tickets about the Parallel-Simple CPAN distribution.

Report information
The Basics
Id: 87874
Status: new
Priority: 0/
Queue: Parallel-Simple

People
Owner: Nobody in particular
Requestors: NHORNE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Can be difficult to debug
This simple case is easy to debug: use Parallel::Simple qw(prun); my @plist = (); my %params; push @plist, [ \&foo, \%params ]; push @plist, [ \&bar, \%params ]; prun(@plist) || warn Parallel::Simple::errplus(); sub foo { print "hello\n"; } sub bar { die "world\n"; } The output is: hello world only 1 of 2 blocks completed successfully 0 => 0 1 => 65280 And it's obvious that the second thread has died. However it's not difficult to conceive a situation where the threads to be started aren't known until runtime and if you have say 5 or 6 (or more) of them you really don't know which block has died. Perhaps named code blocks does that, but the example in the manual doesn't document how to include parameters to the named functions so I don't know how to do that so I can't try that..
I got named blocks with parameters working. Might I suggest including it in the documentation, it would save a lot of grief! Here's my example: #!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Parallel::Simple qw(prun); my @plist = (); my %fparams; my %bparams; $fparams{'name'} = 'ffff'; $bparams{'name'} = 'bbbb'; push @plist, foo => [ \&foo, \%fparams ]; push @plist, bar => [ \&bar, \%bparams ]; prun(@plist) || warn Parallel::Simple::errplus(); sub foo { my $params = shift; my $name = $params->{'name'}; print "$name\n"; } sub bar { my $params = shift; my $name = $params->{'name'}; die "$name\n"; } It gives this output: ffff bbbb only 1 of 2 blocks completed successfully bar => 65280 foo => 0