c++ - Best practices: syncing between threads -


What is it that is almost always necessary to synchronize threads (i.e. use of mutes, scomphrs, important sections, etc.) cross-thread To access the data, even after analyzing the requirements it is not needed?

I have always been recommended to go with the simplest, simplest synchronization scheme until the analysis shows you That's what you should do - it is usually made up of many large locks, which contain many fine locks or lockfree.

The problem is that if the lock-free code is correct, it is more difficult to determine whether the code related to the lock is correct. This creates a huge burden on the maintenance of your code, and there is a good chance that they will find it wrong and present bugs even if you know how locked your code is used, May be safe in the future, may change in the future by people who are not familiar.

Secondly, in many cases, the difference in performance is neglible between the lock and the code with the lock-free code - as long as you do not know that there is a problem with the lock dispute, you are lock-free Should not be considered. Even if there are controversy problems, lock-free is not the best solution.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -