4 ms·
> 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 beli
by dilawar 1y ago
> 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.
- deleted 1y ago[deleted]
- maplant 1y agoIt sounds like you have a deadlock somewhere in your code and it's unlikely that the choice of Mutex really fixed that
- vlovich123 1y agoOr 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.