Wrapper around std::atomic_ref that provides atomic waiting which suspends the calling task instead of blocking it.
More...
#include <coopsync_tbb/atomic_ref_condition.hpp>
|
|
using | value_type = typename std::atomic_ref<T>::value_type |
| | The value type of the atomic_ref_condition, same as the value type of the internal atomic_ref.
|
template<typename T>
class coopsync_tbb::atomic_ref_condition< T >
Wrapper around std::atomic_ref that provides atomic waiting which suspends the calling task instead of blocking it.
- Template Parameters
-
Available only if the standard library supports std::atomic_ref (C++20). Compliance can be checked with COOPSYNC_TBB_HAS_ATOMIC_REF_CONDITION.
◆ atomic_ref_condition() [1/2]
Constructs a new atomic_ref_condition that refers to the given value.
- Parameters
-
| value | A reference to a value to construct the internal atomic_ref from. The value must remain valid for the lifetime of the atomic_ref_condition. |
◆ atomic_ref_condition() [2/2]
The atomic_ref_condition is copy-constructible. The copy constructor creates a new atomic_ref_condition that refers to the same internal atomic object as the original but does not share the waiting queue.
- Parameters
-
◆ ~atomic_ref_condition()
◆ atomic() [1/2]
Access to the internal atomic_ref value.
- Returns
- Const reference to the internal atomic_ref value. Remains valid for the lifetime of the atomic_ref_condition.
◆ atomic() [2/2]
Access to the internal atomic_ref value.
- Returns
- Reference to the internal atomic_ref value. Remains valid for the lifetime of the atomic_ref_condition.
◆ operator*() [1/2]
Access to the internal atomic_ref value.
- Returns
- Const reference to the internal atomic_ref value. Remains valid for the lifetime of the atomic_ref_condition.
◆ operator*() [2/2]
Access to the internal atomic_ref value.
- Returns
- Reference to the internal atomic_ref value. Remains valid for the lifetime of the atomic_ref_condition.
◆ operator->() [1/2]
Access to the internal atomic_ref value.
- Returns
- Const pointer to the internal atomic_ref value. Remains valid for the lifetime of the atomic_ref_condition.
◆ operator->() [2/2]
Access to the internal atomic_ref value.
- Returns
- Pointer to the internal atomic_ref value. Remains valid for the lifetime of the atomic_ref_condition.
◆ wait()
Suspends the calling task until the internal atomic_ref value is not equal to specified value. If the internal atomic_ref value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once associated notify function is called and the internal atomic_ref value is not equal to old.
- Parameters
-
| old | The value to compare the internal atomic_ref value to. The task will be suspended while the internal atomic_ref value is equal to old. |
| order | The memory order to use for loading the internal atomic_ref value. Must not be std::memory_order_release or std::memory_order_acq_rel. |
- Note
- Due to ABA problem, transitions from old to a different value and back to old may be missed.
-
The comparison is done by bitwise comparison of the internal atomic_ref value and old, not by
operator==. The comparison may be affected by padding bytes.
The documentation for this class was generated from the following file: