rohrkabel icon indicating copy to clipboard operation
rohrkabel copied to clipboard

fix sender waits until receiver attaches

Open frogarian opened this issue 5 months ago • 1 comments

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).

frogarian avatar Oct 10 '25 14:10 frogarian

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).

Curve avatar Oct 10 '25 17:10 Curve