Module ForkJoinPool

module ForkJoinPool: sig .. end
Thread pools for fork/join computations.

type t = java'util'concurrent'ForkJoinPool java_instance
The type of thread pools to be used for fork/join computations.
 
val make : ?parallelism:java_int -> bool -> t
make parallelism:p async returns a new thread pool with parallelism p (target number of active threads in pool). If async is true, then a FIFO scheduling is used for tasks. See ForkJoinPool(...).
Raises Java_exception if p is less than 1
 
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_thread_count : t -> java_int
Returns an estimate of the number of active threads in the pool; see getActiveThreadCount(...).
 
val get_async_mode : t -> bool
Returns the asynchronous mode of the pool; see getAsyncMode(...).
 
val get_parallelism : t -> java_int
Returns the parallelism of the pool; see getParallelism(...).
 
val get_pool_size : t -> java_int
Returns the number of threads that have started and not terminated in the pool; see getPoolSize(...).
 
val get_queued_submission_count : t -> java_int
Returns an estimate of the number of tasks submitted (but unstarted) to the pool; see getQueuedSubmissionCount(...).
 
val get_queued_task_count : t -> java_long
Returns an estimate of the number of tasks currently queued in the pool; see getQueuedTaskCount(...).
 
val get_running_thread_count : t -> java_int
Returns an estimate of the number of threads in the pool; see getRunningThreadCount(...).
 
val get_steal_count : t -> java_long
Returns an estimate of the number of tasks stolen from one thread by another one in the pool; see getStealCount(...).
 
val has_queued_submissions : t -> bool
Tests whether there are submitted but unstarted tasks in the pool; see hasQueuedSubmissions(...).
 
val is_quiescent : t -> bool
Tests whether all threads in the pool are idle; see isQuiescent(...).
 
val is_shutdown : t -> bool
Tests whether the pool has been shutdown; see isShutdown(...).
 
val is_terminated : t -> bool
Tests whether shutdown is completed (including all tasks); see isTerminated(...).
 
val is_terminating : t -> bool
Tests whether the pool is in the process shutdowning; see isTerminating(...).
 
val shutdown : t -> unit
Begins a shutdown, executing all submitted tasks, but refusing new tasks; see shutdown(...).
 
val shutdown_now : t -> unit
Begins a shhutdown by cancelling all submitted tasks, and cancelling running tasks; see shutdownNow(...).
 

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.