Module Core_kernel.Pool
module Tuple_type = Tuple_typemodule type S = Pool_intf.SThis uses a Uniform_array.t to implement the pool. We expose that Pointer.t is an int so that OCaml can avoid the write barrier, due to knowing that Pointer.t isn't an OCaml pointer.
module Slots : Tuple_type.Slotsmodule Slot : Tuple_type.Slotmodule Pointer : sig ... end- type 'slots t
- A pool. - 'slotswill look like- ('a1, ..., 'an) Slots.tn, and the pool holds tuples of type- 'a1 * ... * 'an.
- val sexp_of_t : ('slots -> Ppx_sexp_conv_lib.Sexp.t) -> 'slots t -> Ppx_sexp_conv_lib.Sexp.t
- val invariant : 'a Base__.Invariant_intf.inv -> 'a t Base__.Invariant_intf.inv
- val pointer_is_valid : 'slots t -> 'slots Pointer.t -> Core_kernel__.Import.bool
- pointer_is_valid t pointerreturns- trueiff- pointerpoints to a live tuple in- t, i.e.- pointeris not null, not free, and is in the range of- t.- A pointer might not be in the range of a pool if it comes from another pool for example. In this case unsafe_get/set functions would cause a segfault. 
- val id_of_pointer : 'slots t -> 'slots Pointer.t -> Pointer.Id.t
- id_of_pointer t pointerreturns an id that is unique for the lifetime of- pointer's tuple. When the tuple is freed, the id is no longer valid, and- pointer_of_id_exnwill fail on it.- Pointer.null ()has a distinct id from all non-null pointers.
- val pointer_of_id_exn : 'slots t -> Pointer.Id.t -> 'slots Pointer.t
- pointer_of_id_exn t idreturns the pointer corresponding to- id. It fails if the tuple corresponding to- idwas already- freed.
- val create : ('tuple, 'a) Slots.t -> capacity:Core_kernel__.Import.int -> dummy:'tuple -> ('tuple, 'a) Slots.t t
- create slots ~capacity ~dummycreates an empty pool that can hold up to- capacityN-tuples. The slots of- dummyare stored in free tuples.- createraises if- capacity < 0 || capacity > max_capacity ~slots_per_tuple.
- val max_capacity : slots_per_tuple:Core_kernel__.Import.int -> Core_kernel__.Import.int
- max_capacityreturns the maximum capacity allowed when creating a pool.
- val capacity : 'a t -> Core_kernel__.Import.int
- capacityreturns the maximum number of tuples that the pool can hold.
- val length : 'a t -> Core_kernel__.Import.int
- lengthreturns the number of tuples currently in the pool.- 0 <= length t <= capacity t
- val grow : ?capacity:Core_kernel__.Import.int -> 'a t -> 'a t
- grow t ~capacityreturns a new pool- t'with the supplied capacity. The new pool is to be used as a replacement for- t. All live tuples in- tare now live in- t', and valid pointers to tuples in- tare now valid pointers to the identical tuple in- t'. It is an error to use- tafter calling- grow t.- growraises if the supplied capacity isn't larger than- capacity t.
- val is_full : 'a t -> Core_kernel__.Import.bool
- is_full treturns- trueif no more tuples can be allocated in- t.
- val free : 'slots t -> 'slots Pointer.t -> Core_kernel__.Import.unit
- free t pointerfrees the tuple pointed to by- pointerfrom- t.
- val unsafe_free : 'slots t -> 'slots Pointer.t -> Core_kernel__.Import.unit
- unsafe_free t pointerfrees the tuple pointed to by- pointerwithout checking- pointer_is_valid
- val new1 : 'a0 Slots.t1 t -> 'a0 -> 'a0 Slots.t1 Pointer.t
- new<N> t a0 ... a<N-1>returns a new tuple from the pool, with the tuple's slots initialized to- a0...- a<N-1>.- newraises if- is_full t.
- val new2 : ('a0, 'a1) Slots.t2 t -> 'a0 -> 'a1 -> ('a0, 'a1) Slots.t2 Pointer.t
- val new3 : ('a0, 'a1, 'a2) Slots.t3 t -> 'a0 -> 'a1 -> 'a2 -> ('a0, 'a1, 'a2) Slots.t3 Pointer.t
- val new4 : ('a0, 'a1, 'a2, 'a3) Slots.t4 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> ('a0, 'a1, 'a2, 'a3) Slots.t4 Pointer.t
- val new5 : ('a0, 'a1, 'a2, 'a3, 'a4) Slots.t5 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> ('a0, 'a1, 'a2, 'a3, 'a4) Slots.t5 Pointer.t
- val new6 : ('a0, 'a1, 'a2, 'a3, 'a4, 'a5) Slots.t6 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5) Slots.t6 Pointer.t
- val new7 : ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6) Slots.t7 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6) Slots.t7 Pointer.t
- val new8 : ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7) Slots.t8 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7) Slots.t8 Pointer.t
- val new9 : ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8) Slots.t9 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8) Slots.t9 Pointer.t
- val new10 : ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9) Slots.t10 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9 -> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9) Slots.t10 Pointer.t
- val new11 : ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10) Slots.t11 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9 -> 'a10 -> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10) Slots.t11 Pointer.t
- val new12 : ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11) Slots.t12 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9 -> 'a10 -> 'a11 -> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11) Slots.t12 Pointer.t
- val new13 : ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11, 'a12) Slots.t13 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9 -> 'a10 -> 'a11 -> 'a12 -> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11, 'a12) Slots.t13 Pointer.t
- val new14 : ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11, 'a12, 'a13) Slots.t14 t -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9 -> 'a10 -> 'a11 -> 'a12 -> 'a13 -> ('a0, 'a1, 'a2, 'a3, 'a4, 'a5, 'a6, 'a7, 'a8, 'a9, 'a10, 'a11, 'a12, 'a13) Slots.t14 Pointer.t
- val get_tuple : ('tuple, 'a) Slots.t t -> ('tuple, 'a) Slots.t Pointer.t -> 'tuple
- get_tuple t pointerallocates an OCaml tuple isomorphic to the pool- t's tuple pointed to by- pointer. The tuple gets copied, but its slots do not.
- val get : ('a, 'variant) Slots.t t -> ('a, 'variant) Slots.t Pointer.t -> ('variant, 'slot) Slot.t -> 'slot
- get t pointer slotgets- slotof the tuple pointed to by- pointerin pool- t.- set t pointer slot asets to- athe- slotof the tuple pointed to by- pointerin pool- t.- In - getand- set, it is an error to refer to a pointer that has been- freed. It is also an error to use a pointer with any pool other than the one the pointer was- new'd from or- grown to. These errors will lead to undefined behavior, but will not segfault.- unsafe_getis comparable in speed to- getfor immediate values, and 5%-10% faster for pointers.- unsafe_getand- unsafe_setskip bounds checking, and can thus segfault.
- val unsafe_get : ('a, 'variant) Slots.t t -> ('a, 'variant) Slots.t Pointer.t -> ('variant, 'slot) Slot.t -> 'slot
- val set : ('a, 'variant) Slots.t t -> ('a, 'variant) Slots.t Pointer.t -> ('variant, 'slot) Slot.t -> 'slot -> Core_kernel__.Import.unit
- val unsafe_set : ('a, 'variant) Slots.t t -> ('a, 'variant) Slots.t Pointer.t -> ('variant, 'slot) Slot.t -> 'slot -> Core_kernel__.Import.unit
- module Unsafe : sig ... end
- An - Unsafepool is like an ordinary pool, except that the- createfunction does not require an initial element. The pool stores a dummy value for each slot. Such a pool is only safe if one never accesses a slot from a- freed tuple.
- module Debug : functor (Pool : S) -> sig ... end
- Debugbuilds a pool in which every function can run- invarianton its pool argument(s) and/or print a debug message to stderr, as determined by- !check_invariantand- !show_messages, which are initially both- true.
- module Error_check : functor (Pool : S) -> S
- Error_checkbuilds a pool that has additional error checking for pointers, in particular to detect using a- freed pointer or multiply- freeing a pointer.