|
This is perhaps better code (replacing select_one_to_join and join_some):
sub join_any () {
for (;;sleep(0.01)) {
my @thrs = threads->list(threads::joinable);
return $thrs[0]->join() if (@thrs > 0)
}
}
sub limit_threads ($) {
my ($limit) = @_;
for (; threads->list() > $limit; ) {
handle_result(join_any());
}
}
|