Own asynchronous timer tasks in the managed object lifecycle
Verify Tessera GUI / verify (push) Failing after 7m26s
Verify Tessera GUI / verify (push) Failing after 7m26s
This commit is contained in:
@@ -186,7 +186,7 @@ Events use `block.on("click", callback)` or `block.on("click", callback, "captur
|
||||
|
||||
Event methods `stopPropagation()`, `stopImmediatePropagation()`, `preventDefault()` and `isDefaultPrevented()` control delivery or report cancellation; there is currently no additional host default action to cancel. stopPropagation permits remaining listeners on the current occurrence, while the immediate variant stops them too. Listener order is snapshotted at dispatch start; disconnection before a listener's turn skips it, new connections wait for the next dispatch. The existing onClick setter remains a single compatibility callback, called after other non-capture listeners on that Block. All handlers share the VM call budget, with an explicit 10000-delivery limit that reports failure instead of truncating propagation. Reentrant dispatch of the same active Event is rejected; a completed Event can be reused. See [events.endor](examples/events.endor).
|
||||
|
||||
Visual objects also inherit `onMount(self, mount)` and `onUnmount(self, mount)` no-op methods, which source subclasses can override. Notifications occur once per actual occurrence transition: parents before children when attaching, children before parents when detaching. Updating text, color or geometry keeps an existing Mount and does not remount it. Shared content keeps its Block identity when replaced; hooks describe Mount attachment rather than each mutation of that content. Replacing a container child or switching Page produces the appropriate occurrence transitions, even when two Pages display the same root object. This currently covers the active presentation; native tab/window lifecycle is still pending.
|
||||
Visual objects also inherit `onMount(self, mount)` and `onUnmount(self, mount)` no-op methods, which source subclasses can override. Notifications occur once per actual occurrence transition: parents before children when attaching, children before parents when detaching. Updating text, color or geometry keeps an existing Mount and does not remount it. Shared content keeps its Block identity when replaced; hooks describe Mount attachment rather than each mutation of that content. Replacing a container child or switching Page produces the appropriate occurrence transitions, even when two Pages display the same root object. Mount lifecycle follows the active presentation in each native window.
|
||||
|
||||
Mount synchronization queues hooks after links and geometry are coherent. Hooks execute outside the session lock, under one VM budget per batch, after the source input or native event and before final publication. They may update objects or containers; resulting layout/notification work settles before a complete frame is published. A scalar Console result is evaluated before these deferred hooks. The rendering work budget explicitly fails on non-converging feedback. A hook failure after mount mutation stops that runtime and retains its previously displayed frame; failed PUT candidates preserve the old runtime. Hooks are never invoked by GC or by discarding an execution domain.
|
||||
|
||||
@@ -397,3 +397,46 @@ See [function-types.endor](examples/function-types.endor) for actual Endor sourc
|
||||
This adds no static inference, field-write checks, override variance, generics,
|
||||
effect typing or common native-signature metadata. Native APIs continue to validate
|
||||
their arguments and results at their own boundaries.
|
||||
|
||||
|
||||
### Owner-managed asynchronous tasks
|
||||
|
||||
`ui.after(owner, key, milliseconds, callback)` returns a managed `Task` and runs
|
||||
its zero-argument callback on the existing VM worker after the monotonic deadline.
|
||||
The callback must return Unit. Delay is an integer from 0 to 86,400,000 ms; zero
|
||||
means a later worker turn. The worker currently polls at up to 100-ms idle intervals,
|
||||
so deadlines are minimum delays rather than exact timing guarantees. No timer thread
|
||||
reads or changes VM objects. Ready work shares the same heap as code and native events;
|
||||
bindings, lifecycle and all affected windows settle before publishing a new frame.
|
||||
|
||||
Owners can be Blocks, attached Mounts, open Pages, live Windows, or ordinary objects
|
||||
with attribute storage. Use `ui` for application lifetime. Each owner owns a traced
|
||||
task scope, and tasks trace callbacks/captures. The scheduler and task-to-owner link
|
||||
are weak. Hidden but still-referenced objects keep updating; keeping a task token
|
||||
alone does not keep its owner alive unless the callback explicitly captures it.
|
||||
A source function's normal global environment remains a managed capture.
|
||||
|
||||
The same owner/key supersedes its previous pending task, using the actual managed
|
||||
task identity as the request generation. `task.cancel()` cancels pending work and
|
||||
returns whether it was active. `task.active()` queries eligibility; `task.status()`
|
||||
returns pending/running/completed/cancelled/failed. Cancellation and completion drop
|
||||
the callback and remove the owner slot, including when the caller retained the Task.
|
||||
Already running synchronous callbacks finish before the next input can be processed.
|
||||
|
||||
Closing a Page cancels its tasks and its Mount tasks immediately, including closing
|
||||
and reopening in one input. Switching away or replacing content cancels detached
|
||||
Mount tasks; Page and ordinary Block tasks remain. Moving a Page between windows
|
||||
preserves Page tasks and cancels old Mount tasks. Closing a Window cancels its tasks
|
||||
and the Pages it owns. Reset, DELETE and successful program replacement discard the
|
||||
old scheduler with its VM; the worker validates submission/runtime generation before
|
||||
publication, so stale work cannot update the new heap. A failed replacement keeps
|
||||
the previous runtime and its tasks. Callback errors stop the shared runtime, cancel
|
||||
remaining tasks and preserve the last valid picture; completed writes do not roll back.
|
||||
Scheduling/cancelling in read-only render/binding calls is rejected.
|
||||
|
||||
Limits are 64 pending tasks per owner, 1024 per runtime, and 64 ready callbacks per
|
||||
worker poll, each with 128 frames/100,000 instructions. Remaining ready work stays
|
||||
pending for later polls. This is currently a timer provider and task-lifecycle
|
||||
foundation; network/file providers, await/coroutines and interrupting a blocked
|
||||
native callback are not implemented. See [owned-tasks.endor](examples/owned-tasks.endor)
|
||||
for real Endor code and native buttons.
|
||||
|
||||
Reference in New Issue
Block a user