tokio task won't compile because future is not Send
I'm on tokio 1.38 with the rt-multi-thread feature. Spawning a task that holds a std::rc::Rc across an await gives me:
error: future cannot be sent between threads safely
--> src/main.rs:31:5
|
31 | tokio::spawn(async move {
| ^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not Send
|
help: within the async block, the trait Send is not implemented for Rc<State>
I get that Rc isn't thread-safe, but the task only ever runs on one worker. Why does tokio insist on Send?
4 replies