std/async/internal▲toc

Asynchronous internal primitives

This module defines the primitive asynchronous effects for asynchronous operations (async-awaitstd/async/internal/async-await: (E, V) -> V) and cancelation (async-cancelstd/async/internal/async-cancel: (E, V) -> V). The operations of these effects break the abstraction and should only be used by library implementations.

type async-awaitstd/async/internal/async-await: (E, V) -> V<e,a>

Asynchronous operations have the async-awaitstd/async/internal/async-await: (E, V) -> V effect. Usually there is only one handler for asynchronous operations at the main function using the default handler (inserted automatically if main has the async effect).

type async-cancelstd/async/internal/async-cancel: (E, V) -> V<e,a>

The cancelation effect which allows for cancelation of any outstanding asynchronous (interleaved) operations in a cancelation scope (async-scopestd/async/internal/async-scope: V).

type async-iocstd/async/internal/async-ioc: (E, V) -> V<e,a>

Effect to allow iocstd/core/ioc: E operations to execute in the scope of the handler.

type async-scopestd/async/internal/async-scope: V

An abstract cancelation async-scope.

Internal: Cancel any outstanding async operations of a specific cancelation scope (and all its children)

Call the fun cancel-scopestd/async/internal/cancel-scope: (scope : async-scope) -> async-cancel () operation of the effect async-cancelstd/async/internal/async-cancel: (E, V) -> V.

A scope is the chain starting with the current scope, including parent scopes up to the root scope-id.

type await-resultstd/async/internal/await-result: V -> V<a>

An await result is either canceled, an exception, or a regular return value.

con Cancel
con Result(value : a)

Automatically generated. Tests for the Exception constructor of the await-resultstd/async/internal/await-result: V -> V type.

alias await-setupstd/async/internal/await-setup: V -> V<a> = (evloop : event-loopstd/async/internal/event-loop: V, resume : (result : await-resultstd/async/internal/await-result: V -> V<a>, isdone : boolstd/core/types/bool: V) -> iocstd/core/ioc: E ()) -> iocstd/core/ioc: E errorstd/core/exn/error: V -> V<dispose-fnstd/async/internal/dispose-fn: V>

A function that will setup a primitive await. It gets passed the current event loop and a resumption function, and returns either an error or a dispose function. The resumption gets the await-resultstd/async/internal/await-result: V -> V (cancel, exception, or regular result) and whether this is the last time the resumption is called (isdone).

alias dispose-fnstd/async/internal/dispose-fn: V = () -> iocstd/core/ioc: E ()

Function that disposes any resources for an await call (i.e. clearTimeout) and should ensure that any primitive callback is no longer called.

alias event-loopstd/async/internal/event-loop: V = anystd/core/types/any: V

Abstract type for an external event loop.

fun async-schedule-ioc( action : () -> iocstd/core/ioc: E () ) : async-iocstd/async/internal/async-ioc: (E, V) -> V ()

Internal: perform an I/O operation in the outer async handler in the next event loop tick

Call the fun async-schedule-iocstd/async/internal/async-schedule-ioc: (action : () -> ioc ()) -> async-ioc () operation of the effect async-iocstd/async/internal/async-ioc: (E, V) -> V.

fun no-await( setup : await-setupstd/async/internal/await-setup: V -> V<a>, async-scope : async-scopestd/async/internal/async-scope: V, label : stringstd/core/types/string: V, cb : (await-resultstd/async/internal/await-result: V -> V<a>) -> iocstd/core/ioc: E () ) : async-awaitstd/async/internal/async-await: (E, V) -> V ()

After the setup is performed. cb is performed in the handler scope.

Call the fun no-awaitstd/async/internal/no-await: forall<a> (setup : await-setup<a>, async-scope : async-scope, label : string, cb : (await-result<a>) -> ioc ()) -> async-await () operation of the effect async-awaitstd/async/internal/async-await: (E, V) -> V.

private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/boolstd/core/bool, std/core/orderstd/core/order, std/core/charstd/core/char, std/core/intstd/core/int, std/core/vectorstd/core/vector, std/core/bytesstd/core/bytes, std/core/bslicestd/core/bslice, std/core/stringstd/core/string, std/core/sslicestd/core/sslice, std/core/liststd/core/list, std/core/maybestd/core/maybe, std/core/maybe2std/core/maybe2, std/core/eitherstd/core/either, std/core/resultstd/core/result, std/core/tuplestd/core/tuple, std/core/lazystd/core/lazy, std/core/showstd/core/show, std/core/debugstd/core/debug, std/core/delayedstd/core/delayed, std/core/consolestd/core/console, std/corestd/core