Previous: Conditions, Up: Fibers [Contents][Index]
Promises represent the result of a computation that may or may not complete at some later point in time. They are the primitive upon which asynchronous concurrency is based in JavaScript, whether using promises directly or through the async/await syntax.
Hoot fibers use these host promises under the hood and the
(fibers promises)
module provides the API for doing so. This
is mostly transparent to the programmer, except at program
startup. Programs that use fibers must be called in an async context
in which they receive special values used to resolve or reject the
promise representing the result of the entire program. See Fibers example for a walkthrough of this process.
Make an operation that will complete when promise is resolved. Performing the operation produces one value: a thunk which when called will either return the value or throw an exception.
Suspend the current fiber until promise is resolved. If the promise resolves successfully, one value is returned. Otherwise, an exception is thrown.
Call thunk and resolve the promise with resolved and the returned values. If an exception is thrown, the promise is rejected with rejected and the exception.
resolved and rejected are external host values that are
obtained by calling a Scheme procedure asynchronously from the host.
See the Procedure.call_async
method in JavaScript API reference and the hoot-apply-async
procedure in
Reflection for more information on asynchronous procedure calls.
Previous: Conditions, Up: Fibers [Contents][Index]