package core_kernel

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Module for dealing with weak pointers, i.e., pointers that don't prevent garbage collection of what they point to.

This module is like the OCaml standard library module of the same name, except that it requires that the values in the weak set are heap blocks.

type 'a t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
val create : len:Base.int -> _ t
val length : _ t -> Base.int
val set : 'a t -> Base.int -> 'a Heap_block.t Base.option -> Base.unit
val set_exn : 'a t -> Base.int -> 'a Base.option -> Base.unit

set_exn raises an exception if given Some x with x not being a heap block. This is in addition to raising exceptions on bounds violation as set does.

val get : 'a t -> Base.int -> 'a Heap_block.t Base.option
val is_some : _ t -> Base.int -> Base.bool
val is_none : _ t -> Base.int -> Base.bool
val iter : 'a t -> f:('a -> Base.unit) -> Base.unit
val iteri : 'a t -> f:(Base.int -> 'a -> Base.unit) -> Base.unit
val blit : src:'a t -> src_pos:Base.int -> dst:'a t -> dst_pos:Base.int -> len:Base.int -> Base.unit

blit is generally preferred over get followed by set because, unlike get, it doesn't have to make the value strongly-referenced. Making a value strongly-referenced, even temporarily, may result in delaying its garbage collection by a whole GC cycle.

OCaml

Innovation. Community. Security.