/datum/promise
Represents a promised value that can then be fulfilled (likely by some other execution context). Supports waiting for fulfillment.
You create this datum, give a copy to some other place and call wait()
or wait_for_value()
to wait for fulfillment.
The other place can then call the_promise.fulfill(value)
to fulfill the promise with value value
, this interrupts all the waits.
Procs | |
fulfill | Fulfills the promise with value value . |
---|---|
wait | Wait for the promise to be fulfilled. |
wait_for_value | Wait for the promise to be fulfilled and return the value. |
Proc Details
fulfill
Fulfills the promise with value value
.
@param value The value to fulfill the promise with. @return TRUE if the promise was not already fulfilled, FALSE if it was.
wait
Wait for the promise to be fulfilled.
@param timeout How long to wait for fulfillment. If not provided wait indefinitely. @return TRUE if fulfilled, FALSE if not (due to timeout expiring).
wait_for_value
Wait for the promise to be fulfilled and return the value.
@param timeout How long to wait for fulfillment. If not provided wait indefinitely. @return The value of the promise or null if unfulfilled.