@@ -1468,8 +1468,10 @@ canon ::= ...
14681468 | (canon thread.resume-later (core func <id>?)) 🧵
14691469 | (canon thread.suspend cancellable? (core func <id>?)) 🧵
14701470 | (canon thread.yield cancellable? (core func <id>?)) 🔀
1471- | (canon thread.switch-to cancellable? (core func <id>?)) 🧵
1472- | (canon thread.yield-to cancellable? (core func <id>?)) 🧵
1471+ | (canon thread.suspend-then-resume cancellable? (core func <id>?)) 🧵
1472+ | (canon thread.yield-then-resume cancellable? (core func <id>?)) 🧵
1473+ | (canon thread.suspend-then-promote cancellable? (core func <id>?)) 🧵
1474+ | (canon thread.yield-then-promote cancellable? (core func <id>?)) 🧵
14731475 | (canon error-context.new <canonopt>* (core func <id>?)) 📝
14741476 | (canon error-context.debug-message <canonopt>* (core func <id>?)) 📝
14751477 | (canon error-context.drop (core func <id>?)) 📝
@@ -2089,7 +2091,7 @@ extended for [GC].
20892091
20902092As explained in the [ concurrency explainer] , a thread created by
20912093` thread.new-indirect ` is initially in a suspended state and must be resumed
2092- eagerly or lazily by [ ` thread.yield-to ` ] ( #-threadyield-to ) or
2094+ eagerly or lazily by [ ` thread.yield-then-resume ` ] ( #-threadyield-then-resume ) or
20932095[ ` thread.resume-later ` ] ( #-threadresume-later ) , resp., to begin execution.
20942096
20952097For details, see [ Thread Built-ins] in the concurrency explainer and
@@ -2122,9 +2124,6 @@ explicitly resumed by some other thread calling a built-in such as
21222124the current task was [ cancelled] by the caller; otherwise, ` thread.suspend `
21232125always returns ` false ` .
21242126
2125- A non-` async ` -typed function export that has not yet returned a value traps if
2126- it transitively attempts to call ` thread.suspend ` .
2127-
21282127For details, see [ Thread Built-ins] in the concurrency explainer and
21292128[ ` canon_thread_suspend ` ] in the Canonical ABI explainer.
21302129
@@ -2138,52 +2137,73 @@ For details, see [Thread Built-ins] in the concurrency explainer and
21382137The ` thread.yield ` built-in allows the runtime to potentially switch to any
21392138other thread in the "ready" state, enabling a long-running computation to
21402139cooperatively interleave execution without specifically requesting another
2141- thread to be resumed (as with ` thread.yield-to ` ). If ` cancellable ` is set,
2142- ` thread.yield ` returns whether the current task was [ cancelled] by the caller;
2143- otherwise, ` thread.yield ` always returns ` false ` .
2144-
2145- If ` thread.yield ` is called from a synchronous- or ` async callback ` -lifted
2146- export, it returns immediately without blocking (instead of trapping, as with
2147- other possibly-blocking operations like ` waitable-set.wait ` ). This is because,
2148- unlike other built-ins, ` thread.yield ` may be scattered liberally throughout
2149- code that might show up in the transitive call tree of a synchronous function
2150- call.
2140+ thread to be resumed (as with ` thread.yield-then-resume ` ). If ` cancellable ` is
2141+ set, ` thread.yield ` returns whether the current task was [ cancelled] by the
2142+ caller; otherwise, ` thread.yield ` always returns ` false ` .
21512143
21522144For details, see [ Thread Built-ins] in the concurrency explainer and
21532145[ ` canon_thread_yield ` ] in the Canonical ABI explainer.
21542146
2155- ###### 🧵 ` thread.switch-to `
2147+ ###### 🧵 ` thread.suspend-then-resume `
2148+
2149+ | Synopsis | |
2150+ | -------------------------- | --------------------------------------- |
2151+ | Approximate WIT signature | ` func<cancellable?>(t: thread) -> bool ` |
2152+ | Canonical ABI signature | ` [t:i32] -> [i32] ` |
2153+
2154+ The ` thread.suspend-then-resume ` built-in suspends the [ current thread] and
2155+ immediately resumes execution of the thread ` t ` , trapping if ` t ` is not in a
2156+ "suspended" state. If ` cancellable ` is set, ` thread.suspend-then-resume ` returns
2157+ whether the current task was [ cancelled] by the caller; otherwise,
2158+ ` thread.suspend-then-resume ` always returns ` false ` .
2159+
2160+ For details, see [ Thread Built-ins] in the concurrency explainer and
2161+ [ ` canon_thread_suspend_then_resume ` ] in the Canonical ABI explainer.
2162+
2163+ ###### 🧵 ` thread.yield-then-resume `
21562164
21572165| Synopsis | |
21582166| -------------------------- | --------------------------------------- |
21592167| Approximate WIT signature | ` func<cancellable?>(t: thread) -> bool ` |
21602168| Canonical ABI signature | ` [t:i32] -> [i32] ` |
21612169
2162- The ` thread.switch-to ` built-in suspends the [ current thread] and immediately
2163- resumes execution of the thread ` t ` , trapping if ` t ` is not in a "suspended"
2164- state. If ` cancellable ` is set, ` thread.switch-to ` returns whether the current
2165- task was [ cancelled] by the caller; otherwise, ` thread.switch-to ` always returns
2166- ` false ` .
2170+ The ` thread.yield-then-resume ` built-in immediately resumes execution of the
2171+ thread ` t ` , (trapping if ` t ` is not in a "suspended" state) leaving the [ current
2172+ thread] in a "ready" state so that the runtime can nondeterministically resume
2173+ the current thread at some point in the future. If ` cancellable ` is set,
2174+ ` thread.yield-then-resume ` returns whether the current task was [ cancelled] by
2175+ the caller; otherwise, ` thread.yield-then-resume ` always returns ` false ` .
21672176
21682177For details, see [ Thread Built-ins] in the concurrency explainer and
2169- [ ` canon_thread_switch_to ` ] in the Canonical ABI explainer.
2178+ [ ` canon_thread_yield_then_resume ` ] in the Canonical ABI explainer.
21702179
2171- ###### 🧵 ` thread.yield-to `
2180+ ###### 🧵 ` thread.suspend-then-promote `
21722181
21732182| Synopsis | |
21742183| -------------------------- | --------------------------------------- |
21752184| Approximate WIT signature | ` func<cancellable?>(t: thread) -> bool ` |
21762185| Canonical ABI signature | ` [t:i32] -> [i32] ` |
21772186
2178- The ` thread.yield-to ` built-in immediately resumes execution of the thread ` t ` ,
2179- (trapping if ` t ` is not in a "suspended" state) leaving the [ current thread] in
2180- a "ready" state so that the runtime can nondeterministically resume the current
2181- thread at some point in the future. If ` cancellable ` is set, ` thread.yield-to `
2182- returns whether the current task was [ cancelled] by the caller; otherwise,
2183- ` thread.yield-to ` always returns ` false ` .
2187+ The ` thread.suspend-then-promote ` built-in immediately resumes execution of the
2188+ thread ` t ` if ` t ` is in a "ready" state, in any case leaving the current thread
2189+ in a "suspended" state.
21842190
21852191For details, see [ Thread Built-ins] in the concurrency explainer and
2186- [ ` canon_thread_yield_to ` ] in the Canonical ABI explainer.
2192+ [ ` canon_thread_suspend_then_promote ` ] in the Canonical ABI explainer.
2193+
2194+ ###### 🧵 ` thread.yield-then-promote `
2195+
2196+ | Synopsis | |
2197+ | -------------------------- | --------------------------------------- |
2198+ | Approximate WIT signature | ` func<cancellable?>(t: thread) -> bool ` |
2199+ | Canonical ABI signature | ` [t:i32] -> [i32] ` |
2200+
2201+ The ` thread.yield-then-promote ` built-in immediately resumes execution of the
2202+ thread ` t ` if ` t ` is in a "ready" state, in any case leaving the current thread
2203+ in a "ready" state.
2204+
2205+ For details, see [ Thread Built-ins] in the concurrency explainer and
2206+ [ ` canon_thread_yield_then_promote ` ] in the Canonical ABI explainer.
21872207
21882208###### 🧵② ` thread.spawn-ref `
21892209
@@ -3283,11 +3303,13 @@ For some use-case-focused, worked examples, see:
32833303[ `canon_error_context_drop` ] : CanonicalABI.md#-canon-error-contextdrop
32843304[ `canon_thread_index` ] : CanonicalABI.md#-canon-threadindex
32853305[ `canon_thread_new_indirect` ] : CanonicalABI.md#-canon-threadnew-indirect
3286- [ `canon_thread_suspend` ] : CanonicalABI.md#-canon-threadsuspend
3287- [ `canon_thread_switch_to` ] : CanonicalABI.md#-canon-threadswitch-to
32883306[ `canon_thread_resume_later` ] : CanonicalABI.md#-canon-threadresume-later
3289- [ `canon_thread_yield_to ` ] : CanonicalABI.md#-canon-threadyield-to
3307+ [ `canon_thread_suspend ` ] : CanonicalABI.md#-canon-threadsuspend
32903308[ `canon_thread_yield` ] : CanonicalABI.md#-canon-threadyield
3309+ [ `canon_thread_suspend_then_resume` ] : CanonicalABI.md#-canon-threadsuspend-then-resume
3310+ [ `canon_thread_yield_then_resume` ] : CanonicalABI.md#-canon-threadyield-then-resume
3311+ [ `canon_thread_suspend_then_promote` ] : CanonicalABI.md#-canon-threadsuspend-then-promote
3312+ [ `canon_thread_yield_then_promote` ] : CanonicalABI.md#-canon-threadyield-then-promote
32913313[ `canon_thread_spawn_ref` ] : CanonicalABI.md#-canon-threadspawn-ref
32923314[ `canon_thread_spawn_indirect` ] : CanonicalABI.md#-canon-threadspawn-indirect
32933315[ `canon_thread_available_parallelism` ] : CanonicalABI.md#-canon-threadavailable_parallelism
0 commit comments