Module ThreadPoolExecutor

module ThreadPoolExecutor: sig .. end
Thread pools for futures.

type t 
The type of thread pools to be used for futures.
val make : int32 ->
int32 ->
int64 -> TimeUnit.t -> RejectedExecutionHandler.t -> t
make cps mps kat u reh returns a new thread pool with: Raises Invalid_argument if a size is negative.
val await_termination : t -> int64 -> TimeUnit.t -> bool
Waits for pool termination, waiting at most wait for t (time value whose unit is u).

Raises Runtime.Interrupted if the thread is interrupted.

val get_active_count : t -> int32
Returns an estimate of the number of active threads in the pool.
val get_completed_task_count : t -> int64
Returns an estimate of the number of completed computations in the pool.
val get_core_pool_size : t -> int32
Returns the core size of the pool.
val get_keep_alive_time : t -> TimeUnit.t -> int64
Returns the keep alive time for thread outside of the core.
val get_largest_pool_size : t -> int32
Returns the largest size reached by the pool.
val get_maximum_pool_size : t -> int32
Returns the maximum size of the pool.
val get_pool_size : t -> int32
Returns an estimate of the current pool size.
val get_rejected_execution_handler : t -> RejectedExecutionHandler.t
Returns the policy for blocked computations.
val get_task_count : t -> int64
Returns an estimate of number of task that have been submitted for execution.
val invoke_all : t -> (unit -> 'a) list -> 'a Future.t list
invoke_all p l submits all functions from l to pool p, and then waits for the completion of all functions. Returns the list of created futures; it is guaranteed that all futures have completed.

Raises Runtime.Interrupted if the thread is interrupted.

val invoke_all_time : t ->
(unit -> 'a) list -> int64 -> TimeUnit.t -> 'a Future.t list
invoke_all_time p l t u is similar to invoke_all p l, except that the current thread will at most wait for t (time value whose unit is u).

Raises Runtime.Interrupted if the thread is interrupted.

val invoke_any : t -> (unit -> 'a) list -> 'a
invoke_any p l submits all function from l to pool p, and then waits for the completion of a function. Returns the value computed by the first function completing its execution.

Raises Runtime.Interrupted if the thread is interrupted.

Raises Failure if no function completes without raising an exception.

val invoke_any_time : t -> (unit -> 'a) list -> int64 -> TimeUnit.t -> 'a
invoke_any_time p l t u is similar to invoke_any p l, except that the current thread will at most wait for t (time value whose unit is u).

Raises Runtime.Interrupted if the thread is interrupted.

Raises Failure if no function completes without raising an exception.

Raises Runtime.Timeout f time has elapsed without any function completing its execution.

val is_shutdown : t -> bool
Tests whether the pool has been shutdown.
val is_terminated : t -> bool
Tests whether the pool has been shutdown.
val is_terminating : t -> bool
Tests whether the pool is in the process shutdowning.
val set_core_pool_size : t -> int32 -> unit
Changes the core size of the pool (number of threads kept in the pool, even if idle).

Raises Invalid_argument if parameter is negative.

val set_keep_alive_time : t -> int64 -> TimeUnit.t -> unit
Changes the keep alive time (how long to keep alive idle threads not in the core).

Raises Invalid_argument if parameter is negative.

val set_maximum_pool_size : t -> int32 -> unit
Changes the maximum pool size (maximum number of threads in the pool).

Raises Invalid_argument if parameter is negative.

val set_rejected_execution_handler : t -> RejectedExecutionHandler.t -> unit
Changes the policy for blocked computations.
val shutdown : t -> unit
Begins a shutdown, executing all submitted tasks, but refusing new tasks.
val shutdown_now : t -> 'a Future.t list
Begins a shhutdown by cancelling all submitted tasks, and cancelling running tasks.
val submit : t -> ('a -> 'b) -> 'a -> 'b Future.t
submit p f x submits to p and returns a future computing f x.

Raises Failure if pool limits are reached.