Skip to content

Commit 49f1732

Browse files
committed
Refactor in preparation for waitable-set
Add Waitable and WaitableSet as internal classes used to implement existing semantics Change ReadableStream abstract interface to avoid coroutines simplify logic Simplify logic and improve CanonicalABI.md description
1 parent f0dab1b commit 49f1732

File tree

5 files changed

+1780
-1457
lines changed

5 files changed

+1780
-1457
lines changed

design/mvp/Async.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,15 @@ when a component exports asynchronously-lifted functions, there can be multiple
164164
tasks alive at once.
165165

166166
In the Canonical ABI explainer, a "task" is represented with the Python
167-
[`Task`] class, which is created by each call to [`canon_lift`] and has
168-
`SyncTask` and `AsyncTask` subclasses to factor out state and behavior only
169-
needed for sync- or async-lifted functions, resp.
167+
[`Task`] class. A new `Task` object is created (by [`canon_lift`]) each time
168+
a component export is called.
170169

171170
### Current Task
172171

173172
At any point in time when executing in Core WebAssembly code, there is a
174-
single, unambiguous **current task**. Thus, whenever a [canonical built-in] is
175-
called by Core WebAssembly code, it is meaningful for the built-in to work in
176-
terms "the current task".
173+
well-defined **current task**. Thus, whenever a [canonical built-in] is called
174+
by Core WebAssembly code, it is meaningful for the built-in to work in terms
175+
"the current task".
177176

178177
The "current task" is modelled in the Canonical ABI's Python code
179178
by implicitly threading the `Task` object created by [`canon_lift`] through all
@@ -192,7 +191,7 @@ is destroyed).
192191

193192
The Canonical ABI's Python code represents the subtask relationship between a
194193
caller `Task` and a callee `Task` via the Python [`Subtask`] class. Whereas a
195-
`Task` object is created by each call to `canon_lift`, a `Subtask` object is
194+
`Task` object is created by each call to [`canon_lift`], a `Subtask` object is
196195
created by each call to [`canon_lower`]. This allows `Subtask`s to store the
197196
state that enforces the caller side of the Canonical ABI rules.
198197

@@ -315,6 +314,9 @@ above). However, there is always *some* parent `Task` and this parent `Task`
315314
is prevented from orphaning its children using the same reference-counting
316315
guard mentioned above for subtasks.
317316

317+
The [Stream State] and [Future State] sections describe the runtime state
318+
maintained for streams and futures by the Canonical ABI.
319+
318320
### Waiting
319321

320322
When a component asynchronously lowers an import, it is explicitly requesting
@@ -344,6 +346,9 @@ same thing which, in the Canonical ABI Python code, is factored out into
344346
[`Task`]'s `wait` method. Thus, the difference between `callback` and
345347
non-`callback` is mostly one of optimization, not expressivity.
346348

349+
The Canonical ABI Python represents waitables with a common [`Waitable`]
350+
base class.
351+
347352
### Backpressure
348353

349354
Once a component exports asynchronously-lifted functions, multiple concurrent
@@ -630,15 +635,17 @@ comes after:
630635

631636
[Canonical ABI Explainer]: CanonicalABI.md
632637
[`canon_lift`]: CanonicalABI.md#canon-lift
638+
[`canon_lift`]: CanonicalABI.md#canon-lift
633639
[`canon_lower`]: CanonicalABI.md#canon-lower
634-
[`canon_lower`]: CanonicalABI.md#canon-task-wait
635640
[`canon_task_wait`]: CanonicalABI.md#-canon-taskwait
636641
[`canon_task_backpressure`]: CanonicalABI.md#-canon-taskbackpressure
637642
[`canon_task_return`]: CanonicalABI.md#-canon-taskreturn
638-
[`Task`]: CanonicalABI.md#runtime-state
639-
[`Task.enter`]: CanonicalABI.md#runtime-state
640-
[`Subtask`]: CanonicalABI.md#runtime-state
641-
[`AsyncTask`]: CanonicalABI.md#runtime-state
643+
[`Task`]: CanonicalABI.md#task-state
644+
[`Task.enter`]: CanonicalABI.md#task-state
645+
[`Waitable`]: CanonicalABI.md#waitable-state
646+
[`Subtask`]: CanonicalABI.md#subtask-state
647+
[Stream State]: CanonicalABI.md#stream-state
648+
[Future State]: CanonicalABI.md#future-state
642649

643650
[Binary Format]: Binary.md
644651
[WIT]: WIT.md

0 commit comments

Comments
 (0)