Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> One caveat though - using a normal std Mutex within an async environment is an antipattern and should not be done - you can cause all sorts of issues & I believe even deadlock your entire code.

True. I used std::mutex with tokio and after a few days my API would not respond unless I restarted the container. I was under the impression that if it compiles, it's gonna just work (fearless concurrency) which is usually the case.



It sounds like you have a deadlock somewhere in your code and it's unlikely that the choice of Mutex really fixed that


Or you do something super expensive while holding the mutex.

Or your server is heavily contended enough that all worker threads are blocked on this mutex and no reactor can make forward progress.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: