Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
relascope opened this issue Oct 29, 2023 · 1 comment
Open

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

relascope opened this issue Oct 29, 2023 · 1 comment

Comments

@relascope
Copy link

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
Copy link
Contributor

falkTX commented Oct 29, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants