From 801768d0dbefc37ff48208f8aaf1e667db1f203d Mon Sep 17 00:00:00 2001 From: c-cube Date: Wed, 28 Jun 2023 15:54:29 +0000 Subject: [PATCH] deploy: 61887100ae8efdad235ab25e3fa5b2da7598104e --- dev/containers-thread/CCBlockingQueue/index.html | 2 +- dev/containers-thread/CCLock/index.html | 2 +- dev/containers-thread/CCPool/index.html | 2 +- dev/containers-thread/CCSemaphore/index.html | 2 +- dev/containers-thread/CCThread/index.html | 2 +- dev/containers-thread/CCTimer/index.html | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dev/containers-thread/CCBlockingQueue/index.html b/dev/containers-thread/CCBlockingQueue/index.html index 46d7519f..f173cf73 100644 --- a/dev/containers-thread/CCBlockingQueue/index.html +++ b/dev/containers-thread/CCBlockingQueue/index.html @@ -1,2 +1,2 @@ -CCBlockingQueue (containers-thread.CCBlockingQueue)

Module CCBlockingQueue

Blocking Queue

This queue has a limited size. Pushing a value on the queue when it is full will block.

type 'a t

Safe-thread queue for values of type 'a

val create : int -> 'a t

Create a new queue of size n. Using n=max_int amounts to using an infinite queue (2^61 items is a lot to fit in memory); using n=1 amounts to using a box with 0 or 1 elements inside.

  • raises Invalid_argument

    if n < 1.

val push : 'a t -> 'a -> unit

push q x pushes x into q, blocking if the queue is full.

val take : 'a t -> 'a

Take the first element, blocking if needed.

val push_list : 'a t -> 'a list -> unit

Push items of the list, one by one.

val take_list : 'a t -> int -> 'a list

take_list n q takes n elements out of q.

val try_take : 'a t -> 'a option

Take the first element if the queue is not empty, return None otherwise.

val try_push : 'a t -> 'a -> bool

try_push q x pushes x into q if q is not full, in which case it returns true. If it fails because q is full, it returns false.

val peek : 'a t -> 'a option

peek q returns Some x if x is the first element of q, otherwise it returns None.

val size : _ t -> int

Number of elements currently in the queue.

val capacity : _ t -> int

Number of values the queue can hold.

\ No newline at end of file +CCBlockingQueue (containers-thread.CCBlockingQueue)

Module CCBlockingQueue

Blocking Queue

This queue has a limited size. Pushing a value on the queue when it is full will block.

type 'a t

Safe-thread queue for values of type 'a

val create : int -> 'a t

Create a new queue of size n. Using n=max_int amounts to using an infinite queue (2^61 items is a lot to fit in memory); using n=1 amounts to using a box with 0 or 1 elements inside.

  • raises Invalid_argument

    if n < 1.

val push : 'a t -> 'a -> unit

push q x pushes x into q, blocking if the queue is full.

val take : 'a t -> 'a

Take the first element, blocking if needed.

val push_list : 'a t -> 'a list -> unit

Push items of the list, one by one.

val take_list : 'a t -> int -> 'a list

take_list n q takes n elements out of q.

val try_take : 'a t -> 'a option

Take the first element if the queue is not empty, return None otherwise.

val try_push : 'a t -> 'a -> bool

try_push q x pushes x into q if q is not full, in which case it returns true. If it fails because q is full, it returns false.

val peek : 'a t -> 'a option

peek q returns Some x if x is the first element of q, otherwise it returns None.

val size : _ t -> int

Number of elements currently in the queue.

val capacity : _ t -> int

Number of values the queue can hold.

\ No newline at end of file diff --git a/dev/containers-thread/CCLock/index.html b/dev/containers-thread/CCLock/index.html index a9345724..59bf2d97 100644 --- a/dev/containers-thread/CCLock/index.html +++ b/dev/containers-thread/CCLock/index.html @@ -1,2 +1,2 @@ -CCLock (containers-thread.CCLock)

Module CCLock

Utils around Mutex

A value wrapped into a Mutex, for more safety.

type 'a t

A value surrounded with a lock

val create : 'a -> 'a t

Create a new protected value.

val with_lock : 'a t -> ('a -> 'b) -> 'b

with_lock l f runs f x where x is the value protected with the lock l, in a critical section. If f x fails, with_lock l f fails too but the lock is released.

val try_with_lock : 'a t -> ('a -> 'b) -> 'b option

try_with_lock l f runs f x in a critical section if l is not locked. x is the value protected by the lock l. If f x fails, try_with_lock l f fails too but the lock is released.

  • since 0.22
module LockRef : sig ... end

Type allowing to manipulate the lock as a reference.

val with_lock_as_ref : 'a t -> f:('a LockRef.t -> 'b) -> 'b

with_lock_as_ref l f calls f with a reference-like object that allows to manipulate the value of l safely. The object passed to f must not escape the function call.

  • since 0.13
val update : 'a t -> ('a -> 'a) -> unit

update l f replaces the content x of l with f x, atomically.

val update_map : 'a t -> ('a -> 'a * 'b) -> 'b

update_map l f computes x', y = f (get l), then puts x' in l and returns y.

  • since 0.16
val mutex : _ t -> Mutex.t

Underlying mutex.

val get : 'a t -> 'a

Atomically get the value in the lock. The value that is returned isn't protected!

val set : 'a t -> 'a -> unit

Atomically set the value.

  • since 0.13
val incr : int t -> unit

Atomically increment the value.

  • since 0.13
val decr : int t -> unit

Atomically decrement the value.

  • since 0.13
val incr_then_get : int t -> int

incr_then_get x increments x, and returns its new value.

  • since 0.16
val get_then_incr : int t -> int

get_then_incr x increments x, and returns its previous value.

  • since 0.16
val decr_then_get : int t -> int

decr_then_get x decrements x, and returns its new value.

  • since 0.16
val get_then_decr : int t -> int

get_then_decr x decrements x, and returns its previous value.

  • since 0.16
val get_then_set : bool t -> bool

get_then_set b sets b to true, and returns the old value.

  • since 0.16
val get_then_clear : bool t -> bool

get_then_clear b sets b to false, and returns the old value.

  • since 0.16
\ No newline at end of file +CCLock (containers-thread.CCLock)

Module CCLock

Utils around Mutex

A value wrapped into a Mutex, for more safety.

type 'a t

A value surrounded with a lock

val create : 'a -> 'a t

Create a new protected value.

val with_lock : 'a t -> ('a -> 'b) -> 'b

with_lock l f runs f x where x is the value protected with the lock l, in a critical section. If f x fails, with_lock l f fails too but the lock is released.

val try_with_lock : 'a t -> ('a -> 'b) -> 'b option

try_with_lock l f runs f x in a critical section if l is not locked. x is the value protected by the lock l. If f x fails, try_with_lock l f fails too but the lock is released.

  • since 0.22
module LockRef : sig ... end

Type allowing to manipulate the lock as a reference.

val with_lock_as_ref : 'a t -> f:('a LockRef.t -> 'b) -> 'b

with_lock_as_ref l f calls f with a reference-like object that allows to manipulate the value of l safely. The object passed to f must not escape the function call.

  • since 0.13
val update : 'a t -> ('a -> 'a) -> unit

update l f replaces the content x of l with f x, atomically.

val update_map : 'a t -> ('a -> 'a * 'b) -> 'b

update_map l f computes x', y = f (get l), then puts x' in l and returns y.

  • since 0.16
val mutex : _ t -> Mutex.t

Underlying mutex.

val get : 'a t -> 'a

Atomically get the value in the lock. The value that is returned isn't protected!

val set : 'a t -> 'a -> unit

Atomically set the value.

  • since 0.13
val incr : int t -> unit

Atomically increment the value.

  • since 0.13
val decr : int t -> unit

Atomically decrement the value.

  • since 0.13
val incr_then_get : int t -> int

incr_then_get x increments x, and returns its new value.

  • since 0.16
val get_then_incr : int t -> int

get_then_incr x increments x, and returns its previous value.

  • since 0.16
val decr_then_get : int t -> int

decr_then_get x decrements x, and returns its new value.

  • since 0.16
val get_then_decr : int t -> int

get_then_decr x decrements x, and returns its previous value.

  • since 0.16
val get_then_set : bool t -> bool

get_then_set b sets b to true, and returns the old value.

  • since 0.16
val get_then_clear : bool t -> bool

get_then_clear b sets b to false, and returns the old value.

  • since 0.16
\ No newline at end of file diff --git a/dev/containers-thread/CCPool/index.html b/dev/containers-thread/CCPool/index.html index f6276207..086048a8 100644 --- a/dev/containers-thread/CCPool/index.html +++ b/dev/containers-thread/CCPool/index.html @@ -1,2 +1,2 @@ -CCPool (containers-thread.CCPool)

Module CCPool

Thread Pool, and Futures

Renamed and heavily updated from CCFuture.

type +'a state =
  1. | Done of 'a
  2. | Waiting
  3. | Failed of exn
module type PARAM = sig ... end
exception Stopped
module Make (P : PARAM) : sig ... end
\ No newline at end of file +CCPool (containers-thread.CCPool)

Module CCPool

Thread Pool, and Futures

Renamed and heavily updated from CCFuture.

type +'a state =
  1. | Done of 'a
  2. | Waiting
  3. | Failed of exn
module type PARAM = sig ... end
exception Stopped
module Make (P : PARAM) : sig ... end
\ No newline at end of file diff --git a/dev/containers-thread/CCSemaphore/index.html b/dev/containers-thread/CCSemaphore/index.html index 6985cab4..22772f9c 100644 --- a/dev/containers-thread/CCSemaphore/index.html +++ b/dev/containers-thread/CCSemaphore/index.html @@ -1,2 +1,2 @@ -CCSemaphore (containers-thread.CCSemaphore)

Module CCSemaphore

Semaphores

type t

A semaphore

val create : int -> t

create n creates a semaphore with initial value n.

  • raises Invalid_argument

    if n <= 0.

val get : t -> int

Current value.

val acquire : int -> t -> unit

acquire n s blocks until get s >= n, then atomically sets s := !s - n.

val release : int -> t -> unit

release n s atomically sets s := !s + n.

val with_acquire : n:int -> t -> f:(unit -> 'a) -> 'a

with_acquire ~n s ~f first acquires s with n units, calls f (), and then releases s with n units. Safely release the semaphore even if f () fails.

val wait_until_at_least : n:int -> t -> f:(unit -> 'a) -> 'a

wait_until_at_least ~n s ~f waits until get s >= n, then calls f () and returns its result. Doesn't modify the semaphore.

\ No newline at end of file +CCSemaphore (containers-thread.CCSemaphore)

Module CCSemaphore

Semaphores

type t

A semaphore

val create : int -> t

create n creates a semaphore with initial value n.

  • raises Invalid_argument

    if n <= 0.

val get : t -> int

Current value.

val acquire : int -> t -> unit

acquire n s blocks until get s >= n, then atomically sets s := !s - n.

val release : int -> t -> unit

release n s atomically sets s := !s + n.

val with_acquire : n:int -> t -> f:(unit -> 'a) -> 'a

with_acquire ~n s ~f first acquires s with n units, calls f (), and then releases s with n units. Safely release the semaphore even if f () fails.

val wait_until_at_least : n:int -> t -> f:(unit -> 'a) -> 'a

wait_until_at_least ~n s ~f waits until get s >= n, then calls f () and returns its result. Doesn't modify the semaphore.

\ No newline at end of file diff --git a/dev/containers-thread/CCThread/index.html b/dev/containers-thread/CCThread/index.html index 6e7ed207..87d6a148 100644 --- a/dev/containers-thread/CCThread/index.html +++ b/dev/containers-thread/CCThread/index.html @@ -1,2 +1,2 @@ -CCThread (containers-thread.CCThread)

Module CCThread

Threads

status: unstable

type t = Thread.t
val spawn : (unit -> _) -> t

spawn f creates a new thread that runs f ().

val spawn1 : ('a -> _) -> 'a -> t

spawn1 f x is like spawn (fun () -> f x).

  • since 0.16
val spawn2 : ('a -> 'b -> _) -> 'a -> 'b -> t

spawn2 f x y is like spawn (fun () -> f x y).

  • since 0.16
val detach : (unit -> 'a) -> unit

detach f is the same as ignore (spawn f).

module Arr : sig ... end

Single-Use Barrier

module Barrier : sig ... end
\ No newline at end of file +CCThread (containers-thread.CCThread)

Module CCThread

Threads

status: unstable

type t = Thread.t
val spawn : (unit -> _) -> t

spawn f creates a new thread that runs f ().

val spawn1 : ('a -> _) -> 'a -> t

spawn1 f x is like spawn (fun () -> f x).

  • since 0.16
val spawn2 : ('a -> 'b -> _) -> 'a -> 'b -> t

spawn2 f x y is like spawn (fun () -> f x y).

  • since 0.16
val detach : (unit -> 'a) -> unit

detach f is the same as ignore (spawn f).

module Arr : sig ... end

Single-Use Barrier

module Barrier : sig ... end
\ No newline at end of file diff --git a/dev/containers-thread/CCTimer/index.html b/dev/containers-thread/CCTimer/index.html index f4af7db9..3e86a83f 100644 --- a/dev/containers-thread/CCTimer/index.html +++ b/dev/containers-thread/CCTimer/index.html @@ -1,2 +1,2 @@ -CCTimer (containers-thread.CCTimer)

Module CCTimer

Event timer

Used to be part of CCFuture.

type t

A scheduler for events. It runs in its own thread.

val create : unit -> t

A new timer.

val set_exn_handler : t -> (exn -> unit) -> unit

set_exn_handler timer f registers f so that any exception raised by a task scheduled in timer is given to f.

exception Stopped
val after : t -> float -> f:(unit -> _) -> unit

Call the callback f after the given number of seconds.

  • raises Stopped

    if the timer was stopped.

val at : t -> float -> f:(unit -> _) -> unit

Create a future that evaluates to () at the given Unix timestamp.

  • raises Stopped

    if the timer was stopped.

exception ExitEvery
val every : ?delay:float -> t -> float -> f:(unit -> _) -> unit

every timer n ~f calls f () every n seconds. f() can raise ExitEvery to stop the cycle.

  • parameter delay

    if provided, the first call to f () is delayed by that many seconds.

  • raises Stopped

    if the timer was stopped.

val stop : t -> unit

Stop the given timer, cancelling pending tasks. Idempotent. From now on, calling most other operations on the timer will raise Stopped.

val active : t -> bool

Return true until stop t has been called.

\ No newline at end of file +CCTimer (containers-thread.CCTimer)

Module CCTimer

Event timer

Used to be part of CCFuture.

type t

A scheduler for events. It runs in its own thread.

val create : unit -> t

A new timer.

val set_exn_handler : t -> (exn -> unit) -> unit

set_exn_handler timer f registers f so that any exception raised by a task scheduled in timer is given to f.

exception Stopped
val after : t -> float -> f:(unit -> _) -> unit

Call the callback f after the given number of seconds.

  • raises Stopped

    if the timer was stopped.

val at : t -> float -> f:(unit -> _) -> unit

Create a future that evaluates to () at the given Unix timestamp.

  • raises Stopped

    if the timer was stopped.

exception ExitEvery
val every : ?delay:float -> t -> float -> f:(unit -> _) -> unit

every timer n ~f calls f () every n seconds. f() can raise ExitEvery to stop the cycle.

  • parameter delay

    if provided, the first call to f () is delayed by that many seconds.

  • raises Stopped

    if the timer was stopped.

val stop : t -> unit

Stop the given timer, cancelling pending tasks. Idempotent. From now on, calling most other operations on the timer will raise Stopped.

val active : t -> bool

Return true until stop t has been called.

\ No newline at end of file