ITask

public interface ITask<T>

Interface for asynchronous task with cancellation.

Parameters:
  • <T> – Type of the result.

Methods

block

ITask<T> block()

Blocks until the task has been completed or cancelled, and return itself.

Throws:

cancel

void cancel()

Request cancellation.

cancel

void cancel(int forceTimeout)

Request cancellation, force cancel after after stopTimeout milliseconds.

Parameters:
  • forceTimeout – Timeout in milliseconds after which the cancellation is forced.

cancelled

boolean cancelled()
Returns:If the task has been cancelled.

completed

boolean completed()
Returns:If the task has been completed.

result

T result()
Returns:Result of the task, or null if it has been cancelled, or not completed yet.

schedule

ITask<T> schedule()

Schedule this task and returns itself.