Passing join handle to select! in a loop #4019
Unanswered
sandeepmukh
asked this question in
Q&A
Replies: 1 comment 2 replies
-
You can do this by passing a mutable reference to the tokio::select! {
result = &mut join_handle => {
// process result
break;
},
event = handle_incoming_messages() => {
// handle messages
},
} This ensures that the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have some async code (a state machine running an algorithm) running in parallel to processing those messages and then terminating once the state machine returns its final state. Is there a way to do this?
Code outline:
Error:
use of moved value:
join_handle
value moved here, in previous iteration of looprustc(E0382)
main.rs(169, 9): move occurs because
join_handle
has typetokio::task::JoinHandle<_>
, which does not implement theCopy
traitmain.rs(178, 22): value moved here, in previous iteration of loop
Beta Was this translation helpful? Give feedback.
All reactions