I'm trying to figure out what can be passed to an "async" task.
says "If a single piece of data must be accessible from more than one task concurrently, then it must be shared using synchronization primitives such as Arc
" Just like regular threads. Rc isn't Send, although Arc is.
and
"Tasks spawned by tokio::spawn
must implement Send
"
This makes sense if you have a multi-threaded async system, because there is real parallelism.
My use case is that I have a huge, interlinked set of data structures with lots of Rc links. It's a client for a virtual world, and the state of all the visible objects is in memory. Updates come in from a queue fed by UDP messages, and some updates require additional HTTP requests to fetch more data. I want to run those HTTP requests in parallel. But I only want one thread at a time updating the world state.
I don't want to have to put Struct tokio::sync::Mutex all over. I'd get deadlocks from locking locks in the wrong order. What I was looking for is less restrictive single-thread async, where Rc can be passed to an async task and there's no need to lock. Is that available?