ae.utils.promise

An implementation of promises.

Modules

await
module ae.utils.promise.await

async/await-like API for asynchronous tasks combining promises and fibers.

concurrency
module ae.utils.promise.concurrency

Promise concurrency tools.

range
module ae.utils.promise.range

Promise range tools.

Members

Classes

Promise
class Promise(T, E : Throwable = Exception)

A promise for a value T or error E.

Functions

all
PromiseValueTransform!(P, x => [x]) all(P[] promises)

Wait for all promises to be resolved, or for any to be rejected.

all
Promise!(AllResult!Promises.ResultType) all(Promises promises)

Heterogeneous variant, which resolves to a tuple. void promises' values are omitted from the result tuple. If all promises are void, then so is the result.

reject
Promise!(T, E) reject(E reason)

Returns a new Promise which is rejected with the given reason.

resolve
Promise!void resolve()

Returns a new Promise!void which is resolved.

resolve
Promise!T resolve(T value)

Returns a new Promise which is resolved with the given value.

Structs

PromiseQueue
struct PromiseQueue(T, E = Exception)

Ordered promise queue, supporting asynchronous enqueuing / fulfillment.

Templates

PromiseError
template PromiseError(P)

Get the error type of the promise P, i.e. its E parameter.

PromiseValue
template PromiseValue(P)

Get the value type of the promise P, i.e. its T parameter.

PromiseValueTransform
template PromiseValueTransform(P, alias transform)

Construct a new Promise type based on P, if the given transformation was applied on the value type. If P is a void Promise, then the returned promise will also be void.

isPromise
template isPromise(P)

Return true if P is a Promise instantiation.

Meta

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Authors

Vladimir Panteleev <ae@cy.md>