Data-Sync-Shared
view release on metacpan or search on metacpan
all.
Data::Sync::Shared::Once - one-time init gate
"enter" returns true for exactly one process (the initializer); all
others block until "done" is called. If the initializer dies,
waiters detect the stale PID and a new initializer is elected.
Features
* File-backed mmap for cross-process sharing
* Futex-based blocking (no busy-spin, no pthread)
* PID-based stale lock recovery (dead process detection)
* Anonymous and memfd modes
* Timeouts on all blocking operations
* eventfd integration for event-loop wakeup
Crash Safety
eg/eventfd_fork.pl view on Meta::CPAN
# Parent: collect notifications
my $collected = 0;
while ($collected < $nworkers) {
my $n = $sem->eventfd_consume;
if (defined $n && $n > 0) {
$collected += $n;
printf " parent: got %d notification(s), total=%d/%d\n",
$n, $collected, $nworkers;
} else {
select(undef, undef, undef, 0.01); # brief sleep, no busy-spin
}
}
waitpid($_, 0) for @pids;
printf "\nall %d workers finished, sem value=%d\n", $nworkers, $sem->value;
lib/Data/Sync/Shared.pm view on Meta::CPAN
detect the stale PID and a new initializer is elected.
=back
=head2 Features
=over
=item * File-backed mmap for cross-process sharing
=item * Futex-based blocking (no busy-spin, no pthread)
=item * PID-based stale lock recovery (dead process detection)
=item * Anonymous and memfd modes
=item * Timeouts on all blocking operations
=item * eventfd integration for event-loop wakeup
=back
( run in 1.367 second using v1.01-cache-2.11-cpan-39bf76dae61 )