Replies: 2 comments 4 replies
-
It's exciting watching you work through these issues as a first timer to this sort of problem. It really illustrates to me the power of Rust: you're solving some extremely hard and risky problems in a way that's going to be safe at runtime. Even though you're definitely struggling to learn the concepts and make the compiler happy, the program you're producing at the end is going to be sound. That makes all that struggle good struggle, because it teaches you and helps you be a better programmer that understands threading better, without risking terrible results in something you've built. |
Beta Was this translation helpful? Give feedback.
-
Stumbled across this series as a fellow FastAPI fan exploring Rust alternatives and thoroughly enjoying it, thank you. Rocket 0.5 has, at last, been fully released as of a couple weeks ago - have you had an opportunity to tinker with it yet and see how it feels compared to the release candidate? |
Beta Was this translation helpful? Give feedback.
-
This discussion thread is a place for you to leave your questions, comments, suggestions, and emoji reactions to this blog post. It's also a great place to leave ideas about what you'd like to see in the rest of this series!
The blog post talks about using
parking_lot::Mutex
to solve the issue of mutating shared data. Bothparking_lot::Mutex
andstd::sync::Mutex
are dangerous in async contexts because they're blocking and can cause deadlocks! Consider this situation:.await
and yields control to the runtime..await
. Future 1 will never finish working and drop the Mutex guard, so the Mutex will never unlock.The solution, already implemented in my fork of
rocket_lamb
, is to usetokio::Mutex
instead. The.lock()
function there is a Future which can be.await
ed.Beta Was this translation helpful? Give feedback.
All reactions