ae.utils.promise

An implementation of promises.

Modules

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.

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.

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.

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>