in reply to Re: Parallel::ForkManager and stack
in thread Parallel::ForkManager and stack

Better solution (since it allows all keycards to be in use at the same time):

foreach my $user (@users) { $pm->wait_one_child() while !@keycards; <----- my $key = pop(@keycards); $pm->start and next; print "$user took the '$key' key\n"; $pm->finish(0, { key => $key }); } $pm->wait_all_children;

Replies are listed 'Best First'.
Re^3: Parallel::ForkManager and stack
by Anonymous Monk on Jan 28, 2016 at 02:19 UTC
    thanks to both of you. I didn't know about wait_one_child(), (and only realized how to use wait_for_available_procs() after seeing your post). This solves my problem