DISTRHO / DPF

DISTRHO Plugin Framework
ISC License
670 stars 97 forks source link

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

Open relascope opened 1 year ago

relascope commented 1 year ago

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.

falkTX commented 1 year ago

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.