Skip to content

Update primitives - #55

Merged
lePereT merged 2 commits into
nextfrom
update_primitives
Nov 12, 2025
Merged

Update primitives#55
lePereT merged 2 commits into
nextfrom
update_primitives

Conversation

@lePereT

@lePereT lePereT commented Nov 12, 2025

Copy link
Copy Markdown
Contributor

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

  • 🐛 Bug Fix
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test

Description

Tightens channel rendezvous semantics and makes waitgroups reusable; trims flakiness in tests.

  • channel.lua

    • Replace ad-hoc GC of stale queue entries with explicit per-op entries and a cancellable flag.
    • Use on_abort to mark losing arms cancelled; pop_active() skips cancelled entries.
    • Preserve buffered behaviour; simplify fast paths; tidy module header.
  • waitgroup.lua

    • Introduce per-generation condition; allocate on first add() from zero, signal on return to zero.
    • wait_op() rechecks after try() and blocks on the current generation only.
    • Guard against negative counters; no spurious wakeups.
  • tests

    • test_channel: assert get() blocks before supplying a value.
    • test_waitgroup: add reuse test; shorten sleeps and timings to reduce runtime; adjust assertions accordingly.

Net effect: correct choice-loss cleanup on channels, waitgroups that can be reused safely, fewer retained waiters, and faster, more deterministic tests.

Manual test

  • 👍 yes

Manual test description

Exercised channel put/get across buffered and unbuffered cases; verified blocked get() unblocks on subsequent put(). Verified waitgroup reuse across multiple generations; confirmed no deadlocks and expected wakeups.

Added tests?

  • 👍 yes

Added to documentation?

  • 🙅 no documentation needed

@lePereT
lePereT merged commit 73207ca into next Nov 12, 2025
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