Module ExecutorCompletionService

module ExecutorCompletionService: sig .. end
Helper entities for thread pool executors.

type t = java'util'concurrent'ExecutorCompletionService java_instance
The type of completion services, providing utilities to wait for future completions.
val make : ThreadPoolExecutor.t -> t
Returns a new completion service based on the passed thread pool; see ExecutorCompletionService(...).
val poll : t -> 'a Future.t option
Returns (and removes from the service) a completed task if any, or returns None; see poll(...).
val poll_time : t -> java_long -> TimeUnit.t -> 'a Future.t option
poll_time s t u is similar to pool s, except that the current thread will at most wait for t (time value whose unit is u); see poll(...).
Raises Java_exception if the thread is interrupted
val submit : t -> ('a -> 'b) -> 'a -> 'b Future.t
val take : t -> 'a Future.t
Waits for a task to complete, and returns it; see take(...).
Raises Java_exception if the thread is interrupted

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.


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.