Skip to content

actively removes stale timers - #63

Merged
lePereT merged 1 commit into
nextfrom
timer-fix
Jun 1, 2026
Merged

actively removes stale timers#63
lePereT merged 1 commit into
nextfrom
timer-fix

Conversation

@lePereT

@lePereT lePereT commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this? (check all applicable)

  • 🐛 Bug Fix
  • ✅ Test

Description

Fixes retention of timer tasks when sleep.sleep_op(...) loses a choice.

Previously, sleep_op scheduled a timer task but did not cancel that task if the operation was aborted before the deadline. This meant losing timeout arms could remain in the timer heap until their deadline expired, retaining the associated suspension and captured values.

Changes:

  • Add indexed heap removal support for timer entries.
  • Make timer scheduling return an idempotent cancellation handle.
  • Propagate cancellation handles through the scheduler and suspension APIs.
  • Register the timer cancellation handle as cleanup for sleep_op.
  • Add a regression test covering repeated losing sleep_op arms.

Manual test

  • 👍 yes

Manual test description

Ran the relevant tests with luajit:

luajit tests/test_sleep-timer_cancel.lua
luajit tests/test_timer.lua
luajit tests/test_sleep.lua
luajit tests/test_op.lua

All passed.

Added tests?

  • 👍 yes

Added to documentation?

  • 🙅 no documentation needed

@lePereT
lePereT merged commit 34675f7 into next Jun 1, 2026
1 check passed
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.

1 participant