api
exec.ch
Declarations in exec.ch
1 declarationsasync
Declarations
Public only
async#
Publicnamespace
namespace async
Ownership: the executor owns the type-erased task frame (`SpawnTask`) and
TaskVTable#
Publicstruct
Type-erased poll/drop table for a spawned task. Non-generic on purpose (B20).
RawTask#
Publicstruct
A queued, type-erased task. Non-generic on purpose (B20).
ExecWakeHook#
Publictypealias
type ExecWakeHook = func(*void) : void
Invoked (outside the executor lock) every time a waker fires. A native event
Executor#
Publicstruct
struct Executor {
var m : mutex
var cv : condvar
var queue : vector<RawTask>
var woken : bool
var wake_hook : ExecWakeHook
var wake_hook_arg : *void
}
exec_wake#
function
func exec_wake(data : *void) : void
exec_drop_waker#
function
func exec_drop_waker(data : *void) : void
executor#
Publicfunction
func executor() : *Executor
The process-wide executor. Created lazily; intentionally never torn down.
executor_set_wake_hook#
Publicfunction
Install a hook that runs whenever the executor is woken. Used by native event
exec_enqueue_task#
Publicfunction
executor_poll_tasks#
Publicfunction
func executor_poll_tasks(e : *Executor, max : uint) : uint
Poll up to `max` queued tasks once each. Tasks that stay `Pending` are moved
executor_wait#
Publicfunction
func executor_wait(e : *Executor, millis : ulong) : void
Park the executor thread until a waker fires or `millis` elapse. The timeout
JoinState#
Publicstruct
struct JoinState<T> {
var m : mutex
var refs : int
var done : bool
var consumed : bool
var cancelled : bool
var result : Poll<T>
var waker : Waker
var vtbl : *FutureTable<T>
}
`spawn` join state, shared (refcounted) by the join handle and the task.
SpawnTask#
Publicstruct
struct SpawnTask<T> {
var state : *JoinState<T>
var inner : FutureHandle<T>
var vtbl : *TaskVTable
}
The executor-owned, type-erased task frame.
spawn_join_drop#
Publicfunction
func spawn_join_drop<T>(frame : *void) : void
spawn_task_drop#
Publicfunction
func spawn_task_drop<T>(frame : *void) : void
spawn#
Publicfunction
Submit `handle` to the executor and return a join handle. Await the result
spawn_local#
Publicfunction
process-wide, so this is currently the same submission as `spawn`; the