chore: Remove obsolete panic comments - #346
Conversation
| // PANIC: When `callback` is called (which owns `tx`), we always call `tx.send()`. So the sender | ||
| // is only dropped after placing a value into the channel and `rx.await` always finds this value | ||
| // there. |
There was a problem hiding this comment.
I think I would preserve the comments as such, explaining why we can unwrap into an Err here and why that typically shouldn't be possible to happen.
| // PANIC: When `callback` is called (which owns `tx`), we always call `tx.send()`. So the sender | |
| // is only dropped after placing a value into the channel and `rx.await` always finds this value | |
| // there. | |
| // This error _should_ never happen: When `callback` is called (which owns `tx`), we always call | |
| // `tx.send()`. So the sender is only dropped after placing a value into the channel. `rx.await` | |
| // should therefore always be able to find this value there. |
There was a problem hiding this comment.
It could also happen when the runtime is shut down. Tasks are aborted in no particular order and the sender task might be cancelled before the receiver task. The comment doesn't account for this.
There was a problem hiding this comment.
I think that blog post doesn't apply here: in our case, the sending happens inside a C callback, so this happens outside the async runtime's control and regardless of it, i.e. the runtime cannot cancel this thread. In fact, the ownership of the sender has been moved inside our callback wrapper, so it is only dropped if and when that callback fires (see implementation of CallbackOnce; this is meant by "callback owns tx").
Therefore, I think the comment still holds: shutting down the runtime does not drop the sender, so if we end up here, we always find the sender alive and we never run into the unwrap() branch.
No description provided.