spawn and wake are using a version of the send function that "will block until space in the internal buffer becomes available".
That means that if the channel is full, and we try to spawn a new task or a call to wake() was made, send will block the thread, the executor will never get the opportunity to free space in the channel's buffer, and the thread will be stuck in a deadlock.
By using try_send, instead of send, the call will return immediately if the channel's buffer is full, and the call to expect will panic, as expected.
spawn
andwake
are using a version of thesend
function that "will block until space in the internal buffer becomes available".That means that if the channel is full, and we try to spawn a new task or a call to
wake()
was made,send
will block the thread, the executor will never get the opportunity to free space in the channel's buffer, and the thread will be stuck in a deadlock.By using
try_send
, instead ofsend
, the call will return immediately if the channel's buffer is full, and the call toexpect
will panic, as expected.