Data-Heap-Shared

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    store (typically obtained from "memfd" in another process). The header is
    validated on attach. Croaks on error. The descriptor you pass is
    duplicated ("F_DUPFD_CLOEXEC"), so it stays yours to close and closing it
    does not disturb the handle.

METHODS
  push
        my $ok = $heap->push($priority, $value);

    Insert a "($priority, $value)" integer pair. Returns true on success, or
    false if the heap is full (see "is_full"). Wakes one blocked "pop_wait"
    waiter.

  pop
        my ($pri, $val) = $heap->pop;

    Remove and return the lowest-priority element as a "($priority, $value)"
    pair. Returns the empty list if the heap is empty.

  pop_wait
        my ($pri, $val) = $heap->pop_wait;         # block forever

heap.h  view on Meta::CPAN


typedef struct {
    uint32_t magic;
    uint32_t version;
    uint64_t capacity;
    uint64_t total_size;
    uint64_t data_off;
    uint8_t  _pad0[32];

    uint32_t size;             /* 64: current element count (futex word for pop) */
    uint32_t mutex;            /* 68: 0=free, HEAP_MUTEX_BIT|pid=locked */
    uint32_t mutex_waiters;    /* 72 */
    uint32_t waiters_pop;      /* 76 */
    uint64_t stat_pushes;      /* 80 */
    uint64_t stat_pops;        /* 88 */
    uint64_t stat_waits;       /* 96 */
    uint64_t stat_timeouts;    /* 104 */
    uint64_t stat_recoveries;  /* 112 */
    uint8_t  _pad1[8];         /* 120-127 */
} HeapHeader;

lib/Data/Heap/Shared.pm  view on Meta::CPAN

closing it does not disturb the handle.

=head1 METHODS

=head2 push

    my $ok = $heap->push($priority, $value);

Insert a C<($priority, $value)> integer pair. Returns true on
success, or false if the heap is full (see L</is_full>). Wakes one
blocked L</pop_wait> waiter.

=head2 pop

    my ($pri, $val) = $heap->pop;

Remove and return the lowest-priority element as a C<($priority,
$value)> pair. Returns the empty list if the heap is empty.

=head2 pop_wait



( run in 0.695 second using v1.01-cache-2.11-cpan-7f9471e7e0a )