jenga

Industrial strength, full-featured build system
IN THIS PACKAGE
Module Tenacious_lib . Ring
type 'a t
type 'a elem
val create : unit -> 'a t

ring = create () Returns a new empty ring

val keep_alive : 'a t -> 'b -> unit

keep_alive ring v makes ring keep v alive in the gc sense. Only one value can be kept alive per ring.

val add : 'a t -> 'a -> 'a elem

elem = add ring x

Adds a value x to an existing ring, returning elem, which is a handle by which the value x can be removed from the ring

val detach : 'a elem -> unit

detach elem

Detaches elem from the ring to which it was added. It is allowed for detach to be called repeatedly on the same elem; subsequent calls have no effect.

val iter : 'a t -> f:( 'a -> unit ) -> unit

iter ring ~f

f is called in turn on each value x which has been added to ring (in the order the x were added) for those x whose associated elem has not been detached.

It is allowed for elements to be detached during an iteration - since calls to detach from a finalizer may preempt a running iter. It is undefined whether f is called on the value x which is preemptively detached.

val add_calling : 'a t -> 'a -> f:( unit -> unit ) -> 'a elem

add_calling t x ~f

Behaves like add t x except f is called part way through the operation. This is not intended to be useful! The purpose is to allow tests which check the behaviour of calling detach part way through an add operation.

val size : 'a t -> int