M4 executors: coroutine executor, tasks, timers, test dispatcher, AsyncApp
- executor: coroutines on MoonBit's async intrinsics (%async.suspend / run / capture_cancellation / raise_cancellation_signal), scheduled by a Dispatcher trait (the platform hook) instead of core/async's event loop; works on wasm, wasm-gc, js and native. - Task[T]: wait (re-raises task errors), cancel (unwinds at the next suspension point, running defers; waiters get TaskCancelled), ready, try_result, detach. Executor: spawn, timer, sleep, yield_now, now. - TestDispatcher: deterministic FIFO queue and virtual clock with GPUI's advance_clock semantics (run, then step to each due timer). - app: AsyncApp, App::spawn, Context::spawn (weak handle), foreground/background executors, run_until_parked / advance_clock; App::new() owns a TestDispatcher unless given a dispatcher. - Tests ported/adapted from the scheduler crate; app async tests; the counter example gains a ticker task. Docs: M4 status and deviations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
64bf747047
commit
eeab51348e
16 files changed
+1108
-13
No files matched your search
@@ -0,0 +1,11 @@
|
||||
///|
|
||||
test "panic on waiting outside a task" {
|
||||
let dispatcher = TestDispatcher::new()
|
||||
let task = Executor::new(dispatcher).timer(1)
|
||||
// A coroutine that is not a task: `wait` cannot suspend it.
|
||||
run_async(() => {
|
||||
capture_cancellation(() => task.wait(), handler=() => ()) catch {
|
||||
_ => ()
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user