Fix potential deadlock in the executor #189
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.