Skip to content

Confused about tokio::select! #3707

Answered by Darksonn
FH0 asked this question in Q&A
Apr 16, 2021 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

The tokio::select! runs the branches you provide it concurrently, but not in parallel. This means that only one branch can do work at any time, and that the macro will alternate between doing work on the branches. Because of this non-parallel approach, it can't happen that two branches become ready at the same time, so e.g. in the linked example, it is not possible to lose a line from the peer because you got a message from peer.rx at the same time.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@OverShifted
Comment options

@Noah-Kennedy
Comment options

Answer selected by FH0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants