package core_kernel

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

Module Weak_pointerSource

A weak pointer is a pointer to a heap block that does not cause the heap block to remain live during garbage collection.

If the block would otherwise remain live, then the weak pointer remains pointed to the block. If the block is collected, then the weak pointer is cleared.

Sourcetype 'a t
Sourceval sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
Sourceval create : Base.unit -> _ t

create creates an empty weak pointer. One must set it to point it to something.

Sourceval create_full : 'a Heap_block.t -> 'a t

create_full is similar to create, but sets the pointer at creation time.

Sourceval get : 'a t -> 'a Heap_block.t Base.option
Sourceval is_some : _ t -> Base.bool

is_some t = Option.is_some (get t).

Sourceval is_none : _ t -> Base.bool

is_none t = Option.is_none (get t).

Sourceval set : 'a t -> 'a Heap_block.t -> Base.unit