Eio_futawait ?abort f waits for the completion of future f and returns its value. The optional abort function is called when the fiber is cancelled.
await_exn ?abort f waits for the completion of future f and returns its value. An exception is raised in case of a JavaScript error. The optional abort function is called when the fiber is cancelled.
make ~sw fn runs fn in a new fiber (attached to sw) and returns a future whose value is the return value of the function. Raises immediately via Eio.Switch.check if sw is already cancelled or finished.
If fn raises an exception (including when its fiber is cancelled), sw fails and the future is never determined: code waiting on it waits forever. Use make_exn when the future may be awaited from JavaScript, so that failures are reported.
make_exn ~sw fn runs fn in a new fiber (attached to sw) and returns a future whose value is either Ok v or Error err if the function raises an exception (without failing sw). A Jv.Error exception is preserved; any other exception is converted to a Jv.Error.t. If sw is already cancelled or finished, fn is not run and the future resolves with the switch error.
Every exception is turned into an error, including Eio.Cancel.Cancelled (when sw is cancelled while fn runs) and exceptions such as Assert_failure that indicate a bug: they are not reported elsewhere, so they are lost if the future is never awaited.