@@ -2111,6 +2111,7 @@ containing the given resource representation in the current component
2111
2111
instance's handle table:
2112
2112
``` python
2113
2113
async def canon_resource_new (rt , task , rep ):
2114
+ trap_if(not task.inst.may_leave)
2114
2115
h = HandleElem(rep, own = True )
2115
2116
i = task.inst.handles.add(rt, h)
2116
2117
return [i]
@@ -2131,6 +2132,7 @@ current component instance's handle table and, if the handle was owning, calls
2131
2132
the resource's destructor.
2132
2133
``` python
2133
2134
async def canon_resource_drop (rt , sync , task , i ):
2135
+ trap_if(not task.inst.may_leave)
2134
2136
inst = task.inst
2135
2137
h = inst.handles.remove(rt, i)
2136
2138
flat_results = [] if sync else [0 ]
@@ -2223,6 +2225,7 @@ caller and lowers them into the current instance:
2223
2225
``` python
2224
2226
async def canon_task_start (task , core_ft , flat_args ):
2225
2227
assert (len (core_ft.params) == len (flat_args))
2228
+ trap_if(not task.inst.may_leave)
2226
2229
trap_if(task.opts.sync)
2227
2230
trap_if(core_ft != flatten_functype(CanonicalOptions(), FuncType([], task.ft.params), ' lower' ))
2228
2231
task.start()
@@ -2253,6 +2256,7 @@ current instance and passes them to the caller:
2253
2256
``` python
2254
2257
async def canon_task_return (task , core_ft , flat_args ):
2255
2258
assert (len (core_ft.params) == len (flat_args))
2259
+ trap_if(not task.inst.may_leave)
2256
2260
trap_if(task.opts.sync)
2257
2261
trap_if(core_ft != flatten_functype(CanonicalOptions(), FuncType(task.ft.results, []), ' lower' ))
2258
2262
task.return_()
@@ -2283,6 +2287,7 @@ returning the event (which is currently simply an `AsyncCallState` value)
2283
2287
and writing the subtask index as an outparam:
2284
2288
``` python
2285
2289
async def canon_task_wait (task , ptr ):
2290
+ trap_if(not task.inst.may_leave)
2286
2291
trap_if(task.opts.callback is not None )
2287
2292
event, payload = await task.wait()
2288
2293
store(task, payload, U32(), ptr)
@@ -2312,6 +2317,7 @@ available, returning whether or not there was such an event as a boolean and,
2312
2317
if there was an event, storing the ` i32 ` event+payload pair as an outparam.
2313
2318
``` python
2314
2319
async def canon_task_poll (task , ptr ):
2320
+ trap_if(not task.inst.may_leave)
2315
2321
ret = task.poll()
2316
2322
if ret is None :
2317
2323
return [0 ]
@@ -2333,6 +2339,7 @@ Calling `$f` calls `Task.yield_`, trapping if called when there is a `callback`.
2333
2339
(When there is a callback, yielding is achieved by returning with the LSB set.)
2334
2340
``` python
2335
2341
async def canon_task_yield (task ):
2342
+ trap_if(not task.inst.may_leave)
2336
2343
trap_if(task.opts.callback is not None )
2337
2344
await task.yield_()
2338
2345
return []
@@ -2353,6 +2360,7 @@ on `enqueued` ensures that supertasks can only drop subtasks once they've been
2353
2360
officially notified of their completion (via ` task.wait ` or callback).
2354
2361
``` python
2355
2362
async def canon_subtask_drop (task , i ):
2363
+ trap_if(not task.inst.may_leave)
2356
2364
subtask = task.inst.async_subtasks.remove(i)
2357
2365
trap_if(subtask.enqueued)
2358
2366
trap_if(subtask.state != AsyncCallState.DONE )
0 commit comments