IPC-ConcurrencyLimit
view release on metacpan or search on metacpan
lib/IPC/ConcurrencyLimit/WithLatestStandby.pm view on Meta::CPAN
# we failed to get the lock, which means there is a newer
# process that can replace us so return/exit - this frees up
# our lock and lets the newer process to move into our position.
$0 = "$old_oh - no-lock-retired"
if $self->{process_name_change};
return;
}
}
# nope - the lock to our left is being held so sleep a while before
# we try again. We use the rand and the formula so that items to the
# right poll faster than items to the left, and to reduce the chance
# that lock holder 1 and lock holder 3 poll lock 2 at the same time
# forever. The formula guarantees that items to the left poll faster,
# and the rand ensures there is jitter.
sleep rand(($poll_time / $locker_id)*2);
}
# assert that $locker_id is 0 at this point.
die "panic: We should not reach this point with \$locker_id larger than 0, got $locker_id"
if $locker_id;
$self->_diag("Got $names->[$locker_id] lock, we are allowed to do work.")
if $self->{debug};
( run in 0.357 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )