module ThreadPoolExecutor: sig .. end
Thread pools for futures.
val make : core_pool_size:java_int ->
max_pool_size:java_int ->
java_long -> TimeUnit.t -> RejectedExecutionHandler.t -> t
make core_pool_size:cps max_pool_size: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.
Raises Java_exception if a size is negative
val await_termination : t -> java_long -> TimeUnit.t -> bool
Waits for pool termination, waiting at most wait for
t (time value
whose unit is
u); see
awaitTermination(...).
Raises Java_exception if the thread is interrupted
val get_active_count : t -> java_int
val get_completed_task_count : t -> java_long
val get_core_pool_size : t -> java_int
val get_largest_pool_size : t -> java_int
val get_maximum_pool_size : t -> java_int
val get_pool_size : t -> java_int
val get_task_count : t -> java_long
Returns an estimate of number of task that have been submitted for
execution; see
getTaskCount(...).
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 Java_exception if the thread is interrupted
val invoke_all_time : t ->
(unit -> 'a) list -> java_long -> 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 Java_exception 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.
RaisesJava_exception if the thread is interrupted
Java_exception if no function completes without raising an
exception
val invoke_any_time : t -> (unit -> 'a) list -> java_long -> 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).
RaisesJava_exception if the thread is interrupted
Java_exception f time has elapsed without any function
completing its execution
Java_exception if no function completes without raising an
exception
val is_shutdown : t -> bool
val is_terminated : t -> bool
val is_terminating : t -> bool
val set_core_pool_size : t -> java_int -> unit
Changes the core size of the pool (number of threads kept in the
pool, even if idle); see
setCorePoolSize(...).
val set_keep_alive_time : t -> java_long -> TimeUnit.t -> unit
Changes the keep alive time (how long to keep alive idle threads not
in the core); see
setKeepAliveTime(...).
val set_maximum_pool_size : t -> java_int -> unit
val shutdown : t -> unit
Begins a shutdown, executing all submitted tasks, but refusing new
tasks; see
shutdown(...).
val shutdown_now : t -> 'a Future.t list
Begins a shhutdown by cancelling all submitted tasks, and cancelling
running tasks; see
shutdownNow(...).
val submit : t -> ('a -> 'b) -> 'a -> 'b Future.t
submit p f x submits to p and returns a future computing f x.
Raises Java_exception if pool limits are reached
Null value
val null : t
The null value.
val is_null : t -> bool
is_null obj returns true iff obj is equal to null.
val is_not_null : t -> bool
is_not_null obj returns false iff obj is equal to null.
Miscellaneous
val wrap : t -> t option
wrap obj wraps the reference
obj into an option type:
Some x if obj is not null;
None if obj is null.
val unwrap : t option -> t
unwrap obj unwraps the option
obj into a bare reference:
Some x is mapped to x;
None is mapped to null.