Forks-Queue
view release on metacpan or search on metacpan
examples/pping.pl view on Meta::CPAN
$q1->end;
for (0 .. 9) {
if (fork() == 0) {
work();
exit;
}
}
my %working;
local $SIG{CHLD} = 'IGNORE';
my ($num_alive, $num_pinged) = 0;
while (my $result = $q2->get) {
if ($result->{start}) {
$working{$result->{start}}++;
next;
}
if ($result->{finished}) {
delete $working{$result->{finished}};
if (!%working) {
$q2->end;
}
next;
}
my $addr = $result->{addr};
my $status = $result->{status};
print "$addr => $status\n";
$num_alive += $status;
$num_pinged++;
}
print "Got response from $num_alive out of $num_pinged queried addresses\n";
exit;
sub work {
my $p;
$q2->put( { start => $$ } );
if ($NetPing_avail) {
$p = Net::Ping->new;
}
while (my @nodes = $q1->get(4)) {
foreach my $ip (@nodes) {
lib/Dir/Flock.pm view on Meta::CPAN
=begin TODO
Heartbeat
a running process should be able to update the timestamp of
their lockfiles (either the mtime known to the filesystem or
in the file data themselves) to let other processes (on the
same and other hosts) know that the locking process is still
alive. Can you do that without releasing the lock?
Include heartbeat data in the file names?
Threads
In _ping_oldest_file , how to detect whether a thread is
still alive? How to detect whether a thread on a remote
machine is still alive?
=end TODO
( run in 0.830 second using v1.01-cache-2.11-cpan-39bf76dae61 )