Data-Pool-Shared

 view release on metacpan or  search on metacpan

pool.h  view on Meta::CPAN

    return rp[1] == ' ' && rp[2] == 'Z';
}
static inline int pool_pid_alive(uint32_t pid) {
    if (pid == 0) return 1; /* no owner recorded, assume alive */
    if (kill((pid_t)pid, 0) == -1 && errno == ESRCH) return 0; /* definitely dead */
    return !pool_pid_is_zombie(pid); /* kill() also succeeds for a zombie -> treat as dead */
}

static inline void pool_make_deadline(double timeout, struct timespec *deadline) {
    clock_gettime(CLOCK_MONOTONIC, deadline);
    if (!(timeout < 1e9)) timeout = 1e9; /* clamp Inf/NaN/huge: avoid UB (time_t) cast -> instant spurious timeout */
    deadline->tv_sec += (time_t)timeout;
    deadline->tv_nsec += (long)((timeout - (double)(time_t)timeout) * 1e9);
    if (deadline->tv_nsec >= 1000000000L) {
        deadline->tv_sec++;
        deadline->tv_nsec -= 1000000000L;
    }
}

static inline int pool_remaining_time(const struct timespec *deadline,
                                       struct timespec *remaining) {

t/04-edge-cases.t  view on Meta::CPAN

$i64->set($s, -1);
is $i64->incr($s), 0, "I64 incr from -1";

$i64->free($s);

# --- F64 edge values ---

my $f64 = Data::Pool::Shared::F64->new(undef, 4);
$s = $f64->alloc;

# Use string->NV so literals produce real Inf/NaN under -Duselongdouble
# (where 9e999 would fit in long double and not overflow to Inf).
my $posinf = "Inf"  + 0;
my $neginf = "-Inf" + 0;
my $nan    = "NaN"  + 0;

# Infinity
$f64->set($s, $posinf);
my $v = $f64->get($s);
ok $v == $posinf, "F64 +Inf";

# -Infinity
$f64->set($s, $neginf);
$v = $f64->get($s);
ok $v == $neginf, "F64 -Inf";

# NaN
$f64->set($s, $nan);
$v = $f64->get($s);
ok $v != $v, "F64 NaN (NaN != NaN)";

# Negative zero
$f64->set($s, -0.0);
$v = $f64->get($s);
ok $v == 0.0, "F64 -0.0 compares equal to 0.0";

# Very small
$f64->set($s, 5e-324);
$v = $f64->get($s);
ok $v > 0 && $v < 1e-300, "F64 denormalized";



( run in 0.706 second using v1.01-cache-2.11-cpan-1191d43216d )