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
struct TaskVTable { var poll : func(*void, *Context) : Poll<Unit> var drop : func(*void) : void }
Type-erased poll/drop table for a spawned task. Non-generic on purpose (B20).
RawTask#
Publicstruct
struct RawTask { var frame : *void var vtbl : *TaskVTable }
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 }
delete#
function
func delete(self : *Executor) : void
exec_wake#
function
func exec_wake(data : *void) : void
exec_clone_waker#
function
func exec_clone_waker(data : *void) : Waker
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.
exec_make_waker#
Publicfunction
func exec_make_waker(e : *Executor) : Waker
executor_set_wake_hook#
Publicfunction
func executor_set_wake_hook(e : *Executor, hook : ExecWakeHook, arg : *void) : void
Install a hook that runs whenever the executor is woken. Used by native event
exec_enqueue_task#
Publicfunction
func exec_enqueue_task(e : *Executor, frame : *void, vtbl : *TaskVTable) : void
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.
delete#
function
func delete(self : *JoinState) : void
`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.
delete#
function
func delete(self : *SpawnTask) : void
The executor-owned, type-erased task frame.
spawn_join_poll#
Publicfunction
func spawn_join_poll<T>(frame : *void, cx : *Context) : Poll<T>
spawn_join_drop#
Publicfunction
func spawn_join_drop<T>(frame : *void) : void
spawn_task_poll#
Publicfunction
func spawn_task_poll<T>(frame : *void, cx : *Context) : Poll<Unit>
spawn_task_drop#
Publicfunction
func spawn_task_drop<T>(frame : *void) : void
spawn#
Publicfunction
func spawn<T>(handle : FutureHandle<T>) : FutureHandle<T>
Submit `handle` to the executor and return a join handle. Await the result
spawn_local#
Publicfunction
func spawn_local<T>(handle : FutureHandle<T>) : FutureHandle<T>
process-wide, so this is currently the same submission as `spawn`; the