fn Future(comptime T: type) type

This is a value that starts out unavailable, until resolve() is called While it is unavailable, functions suspend when they try to get() it, and then are resumed when resolve() is called. At this point the value remains forever available, and another resolve() is not allowed.

Parameters

T: type,

Fields

lock: Lock,
data: T,
available: Available,

Functions

fn get(self: *Self) callconv(.Async) *T

Obtain the value. If it’s not available, wait until it becomes available. Thre…

Obtain the value. If it’s not available, wait until it becomes available. Thread-safe.

fn getOrNull(self: *Self) ?*T

Gets the data without waiting for it. If it’s available, a pointer is returned….

Gets the data without waiting for it. If it’s available, a pointer is returned. Otherwise, null is returned.

fn init() Self

No documentation provided.

fn resolve(self: *Self) void

Make the data become available. May be called only once. Before calling this, m…

Make the data become available. May be called only once. Before calling this, modify the data property.

fn start(self: *Self) callconv(.Async) ?*T

If someone else has started working on the data, wait for them to complete and …

If someone else has started working on the data, wait for them to complete and return a pointer to the data. Otherwise, return null, and the caller should start working on the data. It’s not required to call start() before resolve() but it can be useful since this method is thread-safe.