package uring

  1. Overview
  2. Docs

Module Private.HeapSource

Sourcetype 'a t

A bounded heap of values of type 'a.

Sourceval create : int -> _ t

create n is a heap that holds at most n elements.

Sourcetype 'a entry

An element in a heap.

Sourcetype ptr = private int

The index of an entry.

Sourceval ptr : 'a entry -> ptr

ptr e is the index of e.

  • raises Invalid_arg

    if e has already been freed.

Sourceexception No_space
Sourceval alloc : 'a t -> 'a -> extra_data:'b -> 'a entry

alloc t a ~extra_data adds the value a to t and returns a pointer to that value, or raises No_space if no space exists in t.

  • parameter extra_data

    Prevent this from being GC'd until free is called.

Sourceval free : 'a t -> ptr -> 'a

free t p returns the element referenced by p and removes it from the heap. Has undefined behaviour if p has already been freed.

Sourceval in_use : 'a t -> int

in_use t is the number of entries currently allocated.

OCaml

Innovation. Community. Security.