module ThreadPoolExecutor:sig
..end
type
t
val make : int32 ->
int32 ->
int64 -> TimeUnit.t -> RejectedExecutionHandler.t -> t
make cps mps kat u reh
returns a new thread pool with:cps
as its core pool size (number of threads kept in the pool,
even if idle);mps
as its maximum pool size (maximum number of threads in the
pool);kat
keep alive time (how long to keep alive idle threads not in
the core);u
time unit for kat
;reh
policy for blocked computations.Invalid_argument
if a size is negative.val await_termination : t -> int64 -> TimeUnit.t -> bool
t
(time value
whose unit is u
).
Raises Runtime.Interrupted
if the thread is interrupted.
val get_active_count : t -> int32
val get_completed_task_count : t -> int64
val get_core_pool_size : t -> int32
val get_keep_alive_time : t -> TimeUnit.t -> int64
val get_largest_pool_size : t -> int32
val get_maximum_pool_size : t -> int32
val get_pool_size : t -> int32
val get_rejected_execution_handler : t -> RejectedExecutionHandler.t
val get_task_count : t -> int64
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
val is_terminated : t -> bool
val is_terminating : t -> bool
val set_core_pool_size : t -> int32 -> unit
Raises Invalid_argument
if parameter is negative.
val set_keep_alive_time : t -> int64 -> TimeUnit.t -> unit
Raises Invalid_argument
if parameter is negative.
val set_maximum_pool_size : t -> int32 -> unit
Raises Invalid_argument
if parameter is negative.
val set_rejected_execution_handler : t -> RejectedExecutionHandler.t -> unit
val shutdown : t -> unit
val shutdown_now : t -> 'a Future.t list
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.