package luv

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

Threads.

See Threads in the user guide and Threading and synchronization utilities in libuv.

type t
val self : unit -> t

Returns the representation of the calling thread.

Binds uv_thread_self. See pthread_self(3p).

val equal : t -> t -> bool

Compares two thread values for equality.

Binds uv_thread_equal. See pthread_equal(3p).

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

Starts a new thread, which will run the given function.

Binds uv_thread_create. See pthread_create(3p).

?stack_size does nothing on libuv prior to 1.26.0.

Feature check: Luv.Require.(has thread_stack_size)

val create_c : ?stack_size:int -> ?argument:nativeint -> nativeint -> (t, Error.t) result

Like Luv.Thread.create, but runs a C function by pointer.

The C function should have signature (*)(void*). The default value of ?argument is NULL (0).

?stack_size does nothing on libuv prior to 1.26.0.

Feature check: Luv.Require.(has thread_stack_size)

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

Waits for the given thread to terminate.

Binds uv_thread_join. See pthread_join(3p).

module Priority : sig ... end

Constants for use with Luv.Thread.setpriority.

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

Sets the given thread's priority.

Binds uv_thread_setpriority. See setpriority(3p).

Requires Luv 0.5.13 and libuv 1.48.0.

Feature check: Luv.Require.(has setpriority)

val getpriority : t -> (int, Error.t) result

Gets the given thread's priority.

Binds uv_thread_getpriority. See getpriority(3p).

Requires Luv 0.5.13 and libuv 1.48.0.

Feature check: Luv.Require.(has getpriority)

val setaffinity : t -> bytes -> (bytes, Error.t) result

Sets the thread's processor affinity mask.

Binds uv_thread_setaffinity. See pthread_setaffinity_np(3) and SetProcessAffinityMask.

See Luv.System_info.cpumask_size.

Requires Luv 0.5.13 and libuv 1.45.0.

Feature check: Luv.Require.(has setaffinity)

val getaffinity : t -> (bytes, Error.t) result

Gets the thread's processor affinity mask.

Binds uv_thread_getaffinity. See pthread_setaffinity_np(3) and GetProcessAffinityMask.

See Luv.System_info.cpumask_size.

Requires Luv 0.5.13 and libuv 1.45.0.

Feature check: Luv.Require.(has getaffinity)

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

Returns the number of the CPU on which the calling thread is running.

Binds uv_thread_getcpu.

Requires Luv 0.5.13 and libuv 1.45.0.

Feature check: Luv.Require.(has getcpu)

OCaml

Innovation. Community. Security.