Dex.Future
Description: Reference for Dex.Future

### Class

# DexFuture

#### Description [src]

    final class Dex.Future : GObject.TypeInstance
    {
      /* No available fields */
    }

`DexFuture` is the base class representing a future which may resolve with a value or reject with error at some point in the future.

It is the basis for libdex’s concurrency and parallelism model.

Use futures to represent work in progress and allow consumers to build robust processing chains up front which will complete or fail as futures resolve or reject.

When running on a `DexFiber`, you may use `dex_await()` and similar functions to suspend the current thread and return upon completion of the dependent future.

#### Hierarchy

#### Ancestors

- DexObject

#### Descendants

- DexAsyncPair
- DexBlock
- DexCancellable
- DexDelayed
- DexFiber
- DexFutureSet
- DexPromise
- DexStaticFuture
- DexTimeout
- DexUnixSignal

#### Constructors

###### dex_future_all

Creates a new `DexFuture` that will resolve or reject when all futures either resolve or reject.

###### dex_future_all_race

Creates a new `DexFuture` that will resolve when all futures resolve or reject as soon as the first future rejects.

###### dex_future_all_racev

Creates a new `DexFuture` that resolves when all futures resolve.

###### dex_future_allv

Creates a new `DexFuture` that resolves when all futures resolve.

###### dex_future_any

Creates a new `DexFuture` that will resolve when any dependent future resolves, providing the same result as the resolved future.

###### dex_future_anyv

Creates a new `DexFuture` that resolves when the first future resolves.

###### dex_future_catch

Calls `callback` when `future` rejects.

###### dex_future_catch_loop

Asynchronously calls `callback` when `future` rejects.

###### dex_future_finally

Calls `callback` when `future` resolves or rejects.

###### dex_future_finally_loop

Asynchronously calls `callback` when `future` rejects or resolves.

###### dex_future_first

Creates a new `DexFuture` that resolves or rejects as soon as the first dependent future resolves or rejects, sharing the same result.

###### dex_future_firstv

Creates a new `DexFuture` that resolves or rejects as soon as the first dependent future resolves or rejects, sharing the same result.

###### dex_future_new_for_boolean

Creates a new `DexFuture` and resolves it with `v_bool`.

###### dex_future_new_for_double

Creates a new `DexFuture` and resolves it with `v_double`.

###### dex_future_new_for_errno

Creates a new rejected future using `errno_` as the value of errno for the GError.

since: 0.4

###### dex_future_new_for_error

Creates a read-only `DexFuture` that has rejected.

###### dex_future_new_for_fd

Creates a new future that resolves to `fd`.

since: 0.10

###### dex_future_new_for_float

Creates a new `DexFuture` and resolves it with `v_float`.

###### dex_future_new_for_int

Creates a new `DexFuture` and resolves it with `v_int`.

###### dex_future_new_for_int64

Creates a new `DexFuture` and resolves it with `v_int64`.

###### dex_future_new_for_object

Creates a new `DexFuture` that is resolved with `value`.

###### dex_future_new_for_pointer

Creates a new `DexFuture` that is resolved with `pointer` as a `G_TYPE_POINTER`.

###### dex_future_new_for_string

Creates a new `DexFuture` and resolves it with `string`.

###### dex_future_new_for_uint

Creates a new `DexFuture` and resolves it with `v_uint`.

###### dex_future_new_for_uint64

Creates a new `DexFuture` and resolves it with `v_uint64`.

###### dex_future_new_for_value

Creates a read-only `DexFuture` that has resolved.

###### dex_future_new_infinite

Creates an infinite future that will never resolve or reject. This can be useful when you want to mock a situation of “run forever” unless another future rejects or resolves.

since: 0.4

###### dex_future_new_reject

Creates a new `DexFuture` that is rejected.

###### dex_future_new_take_boxed

Creates a new `DexFuture` that is resolved with `value`.

###### dex_future_new_take_object

Creates a new `DexFuture` that is resolved with `value`.

###### dex_future_new_take_string

Creates a new `DexFuture` and resolves it with `string`.

###### dex_future_new_take_variant

Creates a new `DexFuture` that is resolved with `v_variant`.

###### dex_future_then

Calls `callback` when `future` resolves.

###### dex_future_then_loop

Asynchronously calls `callback` when `future` resolves.

#### Instance methods

###### dex_await

Suspends the current `DexFiber` and resumes when `future` has completed.

###### dex_await_boolean

Awaits on `future` and returns the gboolean result.

###### dex_await_boxed

Awaits on `future` and returns the `G_TYPE_BOXED` based result.

###### dex_await_double

Awaits on `future` and returns the result as an double.

###### dex_await_enum

Awaits on `future` and returns the enum result.

###### dex_await_fd

Awaits on `future` and returns the resulting file-descriptor.

since: 0.10

###### dex_await_flags

Awaits on `future` and returns the flags result.

###### dex_await_float

Awaits on `future` and returns the result as an float.

###### dex_await_int

Awaits on `future` and returns the result as an int.

###### dex_await_int64

Awaits on `future` and returns the result as an int64.

###### dex_await_object

Awaits on `future` and returns the `GObject`-based result.

###### dex_await_pointer

Calls `dex_await()` and returns the value of `g_value_get_pointer()`, otherwise `error` is set if the future rejected.

###### dex_await_string

Awaits on `future` and returns the string result.

###### dex_await_uint

Awaits on `future` and returns the result as an uint.

###### dex_await_uint64

Awaits on `future` and returns the result as an uint64.

###### dex_await_variant

Awaits on `future` and returns the `G_TYPE_VARIANT` based result.

since: 0.4

###### dex_future_disown

Disowns a future, allowing it to run to completion even though there may be no observer interested in the futures completion or rejection.

since: 0.4

###### dex_future_get_name

No description available.

###### dex_future_get_status

No description available.

###### dex_future_get_value

No description available.

###### dex_future_is_pending

This is a convenience function equivalent to calling `dex_future_get_status()` and checking for `DEX_FUTURE_STATUS_PENDING`.

###### dex_future_is_rejected

This is a convenience function equivalent to calling `dex_future_get_status()` and checking for `DEX_FUTURE_STATUS_REJECTED`.

###### dex_future_is_resolved

This is a convenience function equivalent to calling `dex_future_get_status()` and checking for `DEX_FUTURE_STATUS_RESOLVED`.

###### dex_future_list_model_new

Creates a new list model that will initially be empty and after `future` resolves contain the items within it.

since: 1.1

###### dex_future_set_static_name

Sets the name of the future with a static/internal string.

##### Methods inherited from DexObject (2)

###### dex_ref

Acquires a reference on the given object, and increases its reference count by one.

###### dex_unref

Releases a reference on the given object, and decreases its reference count by one.