7 Commits

Author SHA1 Message Date
Julian Brost
8df52ed8c1 AtomicOrLocked: use std::conditional_t and std::is_trivially_copyable_v
std::conditional_t was added in C++14, is_trivially_copyable_v in C++17, both
do the same as the previous implementation and are a bit more compact.
2025-09-05 10:36:29 +02:00
Julian Brost
33b5ed85fe Remove obsolete workaround for GCC 4.x
The fallback implementation was added for GCC 4.x as that didn't yet implement
std::is_trivially_copyable. However, by now we're using C++17 as our language
standard and that wasn't even implemented in GCC 4.x yet[^1]:

    Some C++17 features are available since GCC 5, but support was experimental
    and the ABI of C++17 features was not stable until GCC 9.

Hence, this became more or less dead code and can be removed.

[^1]: https://gcc.gnu.org/projects/cxx-status.html#cxx17
2025-09-05 10:24:25 +02:00
Alexander Aleksandrovič Klimov
fb64c4f057
Atomic#Atomic(): remove superfluous atomic write 2024-11-06 11:37:02 +01:00
Alexander Aleksandrovič Klimov
a77259adc1
Atomic<T>#Atomic(T): fix C++ compliance
by not calling `std::atomic<T>::atomic(void)`.

After the latter the instance "does not contain a T object, and its only valid uses are destruction and initialization by std::atomic_init" which we don't call. So the only safe option is `std::atomic<T>::atomic(T)`.

https://en.cppreference.com/w/cpp/atomic/atomic/atomic
2024-11-05 13:15:22 +01:00
Julian Brost
abe2dfa763 Replace EventuallyAtomic with AtomicOrLocked which falls back to a mutex
Apparently there was a reason for making the members of generated classes
atomic. However, this was only done for some types, others were still accessed
using non-atomic operations. For members of type T::Ptr (i.e.  intrusive_ptr<T>),
this can result in a double free when multiple threads access the same variable
and at least one of them writes to the variable.

This commit makes use of std::atomic<T> for more T (it removes the additional
constraint sizeof(T) <= sizeof(void*)) and uses a type including a mutex for
load and store operations as a fallback.
2022-05-03 12:02:46 +02:00
Alexander A. Klimov
bbe0f2d8c4 mkclass: make .ti class members atomic if possible
... not to have to lock the objects while setting attributes.
2020-07-07 18:24:06 +02:00
Alexander A. Klimov
c385355c38 DaemonCommand: make the atomics a bit more atomic
Just to be sure.

refs #5230
2019-07-16 11:39:09 +02:00