Skip to content

Adds closeable, drainable Mailbox primitive + tests - #60

Merged
lePereT merged 2 commits into
nextfrom
mailbox
Jan 8, 2026
Merged

Adds closeable, drainable Mailbox primitive + tests#60
lePereT merged 2 commits into
nextfrom
mailbox

Conversation

@lePereT

@lePereT lePereT commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

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

  • 🍕 Feature
  • ✅ Test

Description

Adds a new fibers.mailbox module: a closeable, drainable queue intended for structured-concurrency workloads where “end-of-stream” semantics are required without changing Channel behaviour.

  • Introduces MailboxTx/MailboxRx with:

    • tx:send() / rx:recv() operations compatible with Op choice/abort semantics
    • explicit closure and drain behaviour (nil reserved for end-of-stream) and :why() for close reason
    • multi-producer support via tx:clone() and counted sender handles; mailbox closes when the last sender handle closes
  • Adds unit tests covering:

    • rendezvous and buffered modes
    • close + drain semantics for receivers
    • rejection/wakeup semantics for blocked senders on close
    • multi-producer refcounted close behaviour and reason propagation

Manual test

  • 👍 yes

Manual test description

Ran the test suite locally and exercised a simple producer/consumer example with multiple cloned senders, verifying:

  • messages are delivered in order (buffered) / via rendezvous (unbuffered)
  • receivers terminate with nil once closed and drained
  • sends after closure are rejected and :why() reports the close reason

Added tests?

  • 👍 yes

Added to documentation?

  • 🙅 no documentation needed

@lePereT
lePereT merged commit 41e1a06 into next Jan 8, 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