I've developed a semi-complex server application (
https://evcc.io) with web ui. Since web requests are async per nature and I wan't to service them quickly, mutexes are used. I'm now at the point where I realise that sprinkling (un)locks over the code quickly leads to deadlocks and unforeseeable complexity.
What are good patterns to cope with that? Some I could imagine are:
- granular locks, maybe plus rigorous use of getters/setters
- some sort of synchronised data container (also eliminated unwanted/undetected access)
- clear naming scheme/separation of concerns
Are there any best practices/ talks/ presentations I could refer to?
Thanks,
Andi