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
@@ -16,6 +16,7 @@ roadmap.
|
||||
| `experiments/gpui/font` | font descriptors in `text_system.rs` | Ported (`Font`, weights, styles, features, fallbacks) |
|
||||
| `experiments/gpui/style` | `style.rs`, `styled.rs`, Refineable, gpui_macros style helpers | Ported (`Style`/`StyleRefinement`, the full `Styled` fluent API) |
|
||||
| `experiments/gpui/app` | `app.rs`, `entity_map.rs`, `context.rs`, `subscription.rs` | Ported (entities, contexts, notify/observe, typed events and globals, effect flushing) |
|
||||
| `experiments/gpui/executor` | `executor.rs`, `scheduler` crate | Ported (tasks, timers, cancellation, deterministic test dispatcher; single thread) |
|
||||
| `experiments/gpui/layout` | `taffy.rs` | Ported on [`Milky2018/chicle`](https://mooncakes.io/docs/Milky2018/chicle) (flexbox, grid, block) |
|
||||
|
||||
## Example
|
||||
@@ -38,8 +39,9 @@ moon run src/examples/card --target js
|
||||
.text_color(@color.rgb(0x1f2328)).text_sm()
|
||||
```
|
||||
|
||||
`src/examples/counter` shows the app model: two entities talking through
|
||||
notifications, a typed event and a global (`moon run src/examples/counter --target js`).
|
||||
`src/examples/counter` shows the app model and executors: two entities
|
||||
talking through notifications, a typed event and a global, and a task
|
||||
ticking on a simulated clock (`moon run src/examples/counter --target js`).
|
||||
|
||||
The first example that renders in the browser comes with milestone M8; see
|
||||
the roadmap.
|
||||
|
||||
Reference in new issue
Block a user