Repository navigation
feat(channel): add is_disconnected to mpsc and mpmc endpoints - #391
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the new channel disconnection checks.
No open issues 🎉
What changed in this PR
Adds is_disconnected to bounded and unbounded mpsc and mpmc endpoints, addressing #377 and aligning these channels with existing oneshot and watch APIs.
Changes:
- Exposes connection-state checks without sending or receiving.
- Documents that receivers report disconnection after the last sender drops, even while buffered messages remain readable.
- Adds examples, integration tests for endpoint drops and clone counts, and a changelog entry.
| File | Description |
|---|---|
tests-integration/tests/mpsc_test/main.rs |
Tests disconnection, reserved permits, and buffered-message draining. |
tests-integration/tests/mpmc_test/main.rs |
Tests clone-aware disconnection, permits, and buffered messages. |
CHANGELOG.md |
Announces the new methods and receiver semantics. |
asyncband/src/mpsc/unbounded/sender.rs |
Adds the sender check with documentation and an example. |
asyncband/src/mpsc/unbounded/receiver.rs |
Adds the receiver check independent of queued messages. |
asyncband/src/mpsc/bounded/sender.rs |
Adds the sender check and documents permit behavior. |
asyncband/src/mpsc/bounded/receiver.rs |
Adds the receiver check with buffered-message semantics. |
asyncband/src/mpmc/unbounded.rs |
Adds documented checks to both unbounded endpoints. |
asyncband/src/mpmc/queue.rs |
Adds shared sender- and receiver-count queries. |
asyncband/src/mpmc/bounded.rs |
Adds documented checks to both bounded endpoints. |
Review effort: Balanced
tisonkun
left a comment
There was a problem hiding this comment.
Thanks for your contribution! LGTM.
I'll merge this tomorrow if there is no more comment.
|
Could you share a concrete use case where |
|
The need is on the sender side, where there is nothing like |
|
Thanks for sharing. The current shape is good. |
Summary
Closes #377.
Adds
is_disconnectedto the mpsc and mpmc senders and receivers, so callers can tell whether the other side is gone without sending or receiving. A sender reportstrueonce the last receiver is dropped. A receiver reportstrueonce the last sender is dropped, even while queued messages are still receivable, same aswatch. I left the spmc endpoints out to keep this small, happy to add them in a follow-up if you want them