←back to thread

517 points bkolobara | 6 comments | | HN request time: 0.206s | source | bottom
1. dvt ◴[] No.45043355[source]
Using sync locks in an async environment is a code smell, so the Rust code is bad right off the bat. Just stick with async locks and take the tiny performance hit unless you know exactly what you're doing.
replies(2): >>45043377 #>>45052531 #
2. ozgrakkurt ◴[] No.45043377[source]
If I remember correctly tokio Mutex docs mentions you should use std Mutex unless you are holding the lock across an await
replies(2): >>45043572 #>>45044581 #
3. ◴[] No.45043572[source]
4. pwdisswordfishz ◴[] No.45044581[source]
Which is exactly what happens here!
replies(1): >>45049437 #
5. ozgrakkurt ◴[] No.45049437{3}[source]
That section looks like a cut out version of a pseudo code more than actual code.

He could have mem::dropped the lock 50 lines before the await point

6. bkolobara ◴[] No.45052531[source]
I didn't need to hold the lock across the .await point and in that case the official docs recommend a regular lock.