Async-Event-Interval
view release on metacpan or search on metacpan
lib/Async/Event/Interval.pm view on Meta::CPAN
my $ok = eval {
if ($timeout) {
my $handler = sub {
die "Callback timed out after ${timeout} seconds\n"
};
local $SIG{ALRM} = $handler;
# Re-install SIGALRM via POSIX::sigaction with flags=0 to
# explicitly clear SA_RESTART. Perl's default $SIG{ALRM} setup
# leaves SA_RESTART on, which causes the kernel to transparently
# resume select() and other restartable syscalls after SIGALRM â
# silently swallowing the timeout on Linux (and anywhere SA_RESTART
# is the default). The local $SIG{ALRM} above still does the
# safe-signal dispatch to the Perl coderef; sigaction just fixes the
# kernel flags.
my $sigset = POSIX::SigSet->new(POSIX::SIGALRM());
my $sa = POSIX::SigAction->new($handler, $sigset, 0);
my $old = POSIX::SigAction->new();
POSIX::sigaction(POSIX::SIGALRM(), $sa, $old);
lib/Async/Event/Interval.pm view on Meta::CPAN
$$s = 'some string'; # plain string
$$s = { key => 'v' }; # hashref
$$s = [1, 2, 3]; # arrayref
B<Supported values>: Internally L<IPC::Shareable> serializes to JSON by
default, so values must be JSON-representable: scalars (strings/numbers),
arrayrefs, hashrefs, and combinations of those. Blessed objects, code
references, regex references, and globs are B<not> supported and will be
silently lost or corrupt the segment.
Nested references work transparently and cleanup is automatic. Note that
under the hood, each nested hashref/arrayref allocates its own child
shared-memory segment, so very deeply nested structures consume one shm
segment per node:
$$s = { config => { db => { host => 'localhost', port => 5432 } } };
my $host = $$s->{config}{db}{host}; # 'localhost'
B<Updating a stored hashref>: When extending a hashref already in the scalar,
mutate through the dereference directly. Do not fetch the reference into a
( run in 2.861 seconds using v1.01-cache-2.11-cpan-7fcb06a456a )