Data-Heap-Shared

 view release on metacpan or  search on metacpan

Shared.xs  view on Meta::CPAN

  CODE:
    RETVAL = heap_push(h, (int64_t)priority, (int64_t)value);
  OUTPUT:
    RETVAL

void
pop(self)
    SV *self
  PREINIT:
    EXTRACT_HEAP(self);
  PPCODE:
    int64_t p, v;
    if (heap_pop(h, &p, &v)) {
        EXTEND(SP, 2);
        PUSHs(sv_2mortal(newSViv((IV)p)));
        PUSHs(sv_2mortal(newSViv((IV)v)));
    }

void
pop_wait(self, ...)
    SV *self
  PREINIT:
    EXTRACT_HEAP(self);
    double timeout = -1;
  PPCODE:
    if (items > 1) timeout = SvNV(ST(1));
    int64_t p, v;
    if (heap_pop_wait(h, &p, &v, timeout)) {
        EXTEND(SP, 2);
        PUSHs(sv_2mortal(newSViv((IV)p)));
        PUSHs(sv_2mortal(newSViv((IV)v)));
    }

void
peek(self)
    SV *self
  PREINIT:
    EXTRACT_HEAP(self);
  PPCODE:
    int64_t p, v;
    if (heap_peek(h, &p, &v)) {
        EXTEND(SP, 2);
        PUSHs(sv_2mortal(newSViv((IV)p)));
        PUSHs(sv_2mortal(newSViv((IV)v)));
    }

UV
size(self)
    SV *self



( run in 0.936 second using v1.01-cache-2.11-cpan-71847e10f99 )