7 ms·
If you use rust async with a local executor such as the tokio current thread runtime, it provides lightweight cooperative concurrency. There is nothing ever ha
by rklaehn 3y ago
If you use rust async with a local executor such as the tokio current thread runtime, it provides lightweight cooperative concurrency.
There is nothing ever happening at the same time, since you are on a single thread. That is why you don't need synchronization primitives such as Mutex but can live with something lightweight like RefCell. And that is why you can get by with non atomic reference counting smart pointers (Rc instead of Arc).
And it is cooperative in that you have to yield by calling await, otherwise nothing else will run.
What the article argues is that the option concurrent but not parallel, which both tokio and futures support in principle, should be advertised more and maybe even be the default.