4 ms·
> Have you read the post in question? Its a good introduction to C++ Concurrency / memory models. Yes, I have. And yes, I am familiar with the C++ concurrency/
by cpgxiii 4y ago
> Have you read the post in question? Its a good introduction to C++ Concurrency / memory models.
Yes, I have. And yes, I am familiar with the C++ concurrency/memory models discussed here. And, to be clear, nothing in the article is doing anything that couldn't be done just as clearly with std::atomic<bool>& as with std::atomic<bool>*. Obviously, if you actually want to be able to assign to the pointer, then you need the pointer form.
> Indeed, one can argue that when using atomics, the more explicit "store" and "load" functions should be used instead.
Yes, this is the style I strongly prefer. Of course, here it doesn't matter between
a = blah->load();
blah->store(b);
or
a = blah.load();
blah.store(b);
and choosing to use the pointer form is often just introducing nullability where you don't need it.
- kllrnohj 4y ago> choosing to use the pointer form is often just introducing nullability where you don't need it. _Nonnull int* whatever; Tada! Nullability avoided. https://releases.llvm.org/3.8.0/tools/clang/docs/AttributeReference.html#nonnull https://releases.llvm.org/3.8.0/tools/clang/docs/AttributeRe...