DPF icon indicating copy to clipboard operation
DPF copied to clipboard

Thread::fShouldExit should of type std::atomic<bool>

Open relascope opened this issue 2 years ago • 1 comments

AFAIK the C++ keyword volatile has to do with compiler optimization (especially ordering). (it was a little different in C) std::atomic guarantees "undefined behaviour"-free code, when multiple threads access a std::atomic<trivialtype> variable concurrently like it is possible in Thread through internal running Thread and concurrent other threads through the public Thread::signalThreadShouldExit.

relascope avatar Oct 29 '23 23:10 relascope

C++98 does not have std::atomic, which DPF still targets as minimum requirement.

I do not want to introduce new C++ requirements until very strictly necessary. The volatile there is meant more as an indication that it should never be optimized away, as a precaution more than reassurance.

falkTX avatar Oct 29 '23 23:10 falkTX