Disclaimer: I'm a rust noob so might be missing some obvious things here...
So the rule is that when Futures are ran on a multi-threaded runtime (like Tokio), they need to be
Send so that one thread can take a task from another thread for scheduling, and this essentially prevents usage of types that are not
await points. Examples include
I'm not understanding why must these types be
Send. Variables with types like
Rc wrapped in a Future (and it's associated state machine) should never be shared between threads because these Futures should not have two copies executing concurrently on different threads. So it seems to me that being able to hold a
await points even tho they can be transferred as part of a
Future to other threads is perfectly legitimate. Currently I will have to use
Arc instead of
Rc, which is fine but feels really weird because I'm really just accessing these
Arc variables from a single thread at all times. This feels even more weird if I need a mutable field wrapped in an
Arc and have to use
RwLock (from Tokio) instead of a
(Perhaps the runtime is doing some smart optimizations that secretly shares things between threads underneath the hood, but I have not seen discussions of it anywhere...