Is it available to use Rc<RefCell<>> in spawned tasks #4371
Answered
by
Darksonn
ActivePeter
asked this question in
Q&A
-
a |
Beta Was this translation helpful? Give feedback.
Answered by
Darksonn
Jan 2, 2022
Replies: 1 comment
-
In general, a Tokio task may be moved from one thread to another at any
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ActivePeter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In general, a Tokio task may be moved from one thread to another at any
.await
, but it is not safe to move anRc
between threads. So to use anRc
in a spawned task, you must do one of the following:Rc
is sufficiently short-lived that it does not have to exist when you perform an.await
.LocalSet
so that it can't be moved between threads.