Skip to content

Add named Lua timers and fair event dispatch - #8

Merged
Gujiawei-Edinburgh merged 1 commit into
apache:mainfrom
popduke:lua-event-model-generalization
Sep 26, 2026
Merged

Gujiawei-Edinburgh merged 1 commit into
apache:mainfrom
popduke:lua-event-model-generalization

Conversation

@popduke

@popduke popduke commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Lua currently has one timer slot, and a script that repeatedly schedules a zero-delay timer can indefinitely delay readable Source input. This change supports anonymous and named one-shot timers and dispatches eligible events by their deadline or first observed Source readiness, with registration order breaking ties.

  • Add optional ids to setTimeout, clearTimeout, and hasTimeout, plus event.id and event.eligibleAt. clearTimeout replaces clearTimerTask; no alias remains. The unreleased contract keeps specVersion = "1".
  • Share one native-memory budget between Payload storage and timers. Each pending timer is charged an estimated 2 KiB plus three times its UTF-8 id length, without a separate timer-count limit. Delay conversion or timestamp overflow raises a catchable Lua error.
  • Preserve timer ownership and Source ordering through VM initialization, replacement, failure, and shutdown. Update the Lua guide with event fields, cancellation, memory accounting, and the existing VM-wide batch completion boundary; timer ids do not provide independent reliable completion per key.

Validation on macOS arm64 with the pinned Rust 1.97.1 toolchain:

  • tools/verify-rust.sh passed, including strict Clippy, generated plugins, real process lifecycle tests, Rust/Java interoperability, Loom, doctests, and rustdoc. Main-library tests: 809 passed, 6 ignored.
  • Lua tests: 113 passed, 1 ignored. Flow Channel tests: 45 passed. Coverage includes zero-delay fairness, equal deadlines, id validation, overflow, cancellation, memory release, and VM handoff.
  • git diff --check passed.

Linux and other architectures were not run locally. No long-running performance benchmark was performed.

@Gujiawei-Edinburgh
Gujiawei-Edinburgh merged commit 3123608 into apache:main Sep 26, 2026
6 checks passed
@popduke
popduke deleted the lua-event-model-generalization branch September 26, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants