←back to thread

517 points bkolobara | 1 comments | | HN request time: 0s | source
Show context
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 #
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 #
pwdisswordfishz ◴[] No.45044581[source]
Which is exactly what happens here!
replies(1): >>45049437 #
1. ozgrakkurt ◴[] No.45049437[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