package luv

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

Thread-local storage.

See Thread-local storage in libuv.

The interface is currently written in terms of nativeint, the type of pointer-sized raw values. You can store OCaml values in TLS by manipulating and registering them with the GC using Ctypes.Root. The conversions between unit ptr and nativeint are Ctypes.ptr_of_raw_address and Ctypes.raw_address_of_ptr.

A future version of this API is likely to handle GC roots internally, and be directly usable with OCaml values.

type t

Binds uv_key_t.

val create : unit -> (t, Error.t) result

Creates a TLS key.

Binds uv_key_create. See pthread_key_create(3p).

val delete : t -> unit

Deletes a TLS key.

Binds uv_key_delete. See pthread_key_delete(3p).

val get : t -> nativeint

Retrieves the value at a TLS key.

Binds uv_key_get. See pthread_getspecific(3p).

val set : t -> nativeint -> unit

Sets the value at a TLS key.

Binds uv_key_set. See pthread_setspecific(3p).

OCaml

Innovation. Community. Security.