+ 3
Spin lock - need | C++ header files | windows
Hi As we can implement our own linked list or vector or queue data structure, C++ has already given library for all these containers. Do we have some header and default implementation for C++ windows spin lock or not ? Any example code of library usage ? One more question is on need of spin lock. Is it better than mutex or not ?
1 Answer
+ 2
Ketan,
You donât need a header to implement a spinlock - although easier to make use of the atomic library.
In most cases youâd be better off with a mutex, unless you have a specific reason for using a spinlock.
Mutexâs tend to be faster and allow other threads to run - although can be a bit more weight on the cpu with putting the threads to sleep/waking.