Is there such a thing as an atomic |= or and atomic or? If no what is the recommended technique for setting a bit in an variable that needs to be threadsafe? (I am avoiding locks)
Is there such a thing as an atomic |= or and atomic or? If
Share
There is not such thing in C++03, but you can use your vendor specific features. For example you can use
InterlockedOron windows. In C++0x you can useatomic_fetch_or.Note that atomic operations also require locking, although it’s on the hardware level it’s still expensive.