final class Future (View source)

A Future represents the return value or uncaught exception from a task, and exposes an API for cancellation.

The behaviour of a future also allows it to be used as a simple synchronization point even where the task does not return a value explicitly.

Methods

mixed
value()

Shall return (and if necessary wait for) return from task

bool
done()

Shall indicate if the task is completed

bool
cancelled()

Shall indicate if the task was cancelled

bool
cancel()

Shall try to cancel the task Note: If task is running, it will be interrupted.

Details

mixed value()

Shall return (and if necessary wait for) return from task

Return Value

mixed

Exceptions

Error
Killed
Cancelled
Foreign
Throwable

bool done()

Shall indicate if the task is completed

Return Value

bool

bool cancelled()

Shall indicate if the task was cancelled

Return Value

bool

bool cancel()

Shall try to cancel the task Note: If task is running, it will be interrupted.

Warning: Internal function calls in progress cannot be interrupted.

Return Value

bool

Exceptions

Killed
Cancelled