Module ScheduledThreadPoolExecutor

module ScheduledThreadPoolExecutor: sig .. end
Thread pools for scheduled futures.

type t = java'util'concurrent'ScheduledThreadPoolExecutor java_instance
The type of thread pools to be used for scheduled futures.
 
val make : core_pool_size:java_int ->
RejectedExecutionHandler.t -> t
make core_pool_size:cps reh returns a new thread pool with:
  • cps as its core pool size (number of threads kept in the pool, even if idle);
  • reh policy for blocked computations.

Raises Java_exception if cps is negative
 
val await_termination : t -> java_long -> TimeUnit.t -> bool
 
val get_active_count : t -> java_int
 
val get_completed_task_count : t -> java_long
 
val get_continue_existing_periodic_tasks_after_shutdown_policy : t -> bool
Tests whether periodic tasks should continue execution after shutdown; see getContinueExistingPeriodicTasksAfterShutdownPolicy(...).
 
val get_core_pool_size : t -> java_int
 
val get_execute_existing_delayed_tasks_after_shutdown_policy : t -> bool
Tests whether delayed tasks should continue execution after shutdown; see getExecuteExistingDelayedTasksAfterShutdownPolicy(...).
 
val get_keep_alive_time : t -> TimeUnit.t -> java_long
 
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_rejected_execution_handler : t -> RejectedExecutionHandler.t
 
val get_remove_on_cancel_policy : t -> bool
Tests whether tasks should be removed when cancelled; see getRemoveOnCancelPolicy(...).
 
val get_task_count : t -> java_long
 
val invoke_all : t -> (unit -> 'a) list -> 'a Future.t list
 
val invoke_all_time : t ->
(unit -> 'a) list -> java_long -> TimeUnit.t -> 'a Future.t list
 
val invoke_any : t -> (unit -> 'a) list -> 'a
 
val invoke_any_time : t ->
(unit -> 'a) list -> java_long -> TimeUnit.t -> 'a
 
val is_shutdown : t -> bool
 
val is_terminated : t -> bool
 
val is_terminating : t -> bool
 
val schedule : t ->
('a -> 'b) -> 'a -> java_long -> TimeUnit.t -> 'b ScheduledFuture.t
schedule p f x t u is similar to submit p f x, except that the evaluation of f x with start after t (time value whose unit is u).
Raises Java_exception if pool limits are reached
 
val schedule_at_fixed_rate : t ->
('a -> unit) ->
'a -> java_long -> java_long -> TimeUnit.t -> unit ScheduledFuture.t
schedule_at_fixed_rate p f x t d u is similar to schedule p f x t u, except that f x will be re-evaluated at t + d, t + 2 * d, etc.
Raises
  • Java_exception if pool limits are reached
  • Java_exception if d is negative
 
val schedule_with_fixed_delay : t ->
('a -> unit) ->
'a -> java_long -> java_long -> TimeUnit.t -> unit ScheduledFuture.t
schedule_with_fixed_delay p f x t d u is similar to schedule p f x t u, except that f x will be repeatedly re-evaluated, respecting a delay of d between the end of one execution and the beginning of the next one.
Raises
  • Java_exception if pool limits are reached
  • Java_exception if d is negative
 
val set_continue_existing_periodic_tasks_after_shutdown_policy : t -> bool -> unit
Changes whether periodic tasks should continue execution after shutdown; see setContinueExistingPeriodicTasksAfterShutdownPolicy(...).
 
val set_core_pool_size : t -> java_int -> unit
 
val set_execute_existing_delayed_tasks_after_shutdown_policy : t -> bool -> unit
changes whether delayed tasks should continue execution after shutdown; see setExecuteExistingDelayedTasksAfterShutdownPolicy(...).
 
val set_keep_alive_time : t -> java_long -> TimeUnit.t -> unit
 
val set_maximum_pool_size : t -> java_int -> unit
 
val set_rejected_execution_handler : t -> RejectedExecutionHandler.t -> unit
 
val set_remove_on_cancel_policy : t -> bool -> unit
Changes whether tasks should be removed when cancelled.
 
val shutdown : t -> unit
 
val shutdown_now : t -> 'a Future.t list
 
val submit : t -> ('a -> 'b) -> 'a -> 'b Future.t
 

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.