Skip to content

fix sender waits until receiver attaches#17

Open
frogarian wants to merge 1 commit into
Curve:masterfrom
frogarian:fix/sender-wait-until-receiver-attaches
Open

fix sender waits until receiver attaches#17
frogarian wants to merge 1 commit into
Curve:masterfrom
frogarian:fix/sender-wait-until-receiver-attaches

Conversation

@frogarian
Copy link
Copy Markdown
Contributor

When no receiver attaches to the channel, the sender might wait infinitely.

My approach here is up to debate. Adding a timeout parameter to channel_state::emit would be a more flexible option.

One drawback I ran into using my approach was that the sender could have already put a message into the queue (in sender<T>::send), but then fails to emit due to a missing receiver. To cope with that I introduced the draining of the queue in (compare channel.inl).

@Curve
Copy link
Copy Markdown
Owner

Curve commented Oct 10, 2025

I'll have to think about this a little. There are also some asserts in channel to prevent issues like this (which don't apply here obviously), but I'm not a fan of exceptions.

I think a more sane approach could be to handle this with std::expected and a timeout parameter (which defaults to 0ms as to avoid a breaking change).

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