Wrapper around std::atomic that provides atomic waiting which suspends the calling task instead of blocking it.
More...
#include <coopsync_tbb/atomic_condition.hpp>
|
|
using | value_type = typename std::atomic<T>::value_type |
| | The value type of the atomic_condition, same as the value type of the internal atomic.
|
|
|
| atomic_condition ()=default |
| | Constructs a new atomic_condition. No initialization of the atomic value takes place.
|
| | atomic_condition (T value) |
| | Constructs a new atomic_condition with the given initial value. This operation is not atomic.
|
|
| atomic_condition (const atomic_condition &)=delete |
| | The atomic_condition is not copy-constructible.
|
|
atomic_condition & | operator= (const atomic_condition &)=delete |
| | The atomic_condition is not copy-assignable.
|
|
| atomic_condition (atomic_condition &&)=delete |
| | The atomic_condition is not move-constructible.
|
|
atomic_condition & | operator= (atomic_condition &&)=delete |
| | The atomic_condition is not move-assignable.
|
| | ~atomic_condition () |
| | Destroys the atomic_condition.
|
| void | wait (value_type old, std::memory_order order=std::memory_order_seq_cst) |
| | Suspends the calling task until the internal atomic value is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once notify_one or notify_all is called and the internal atomic value is not equal to old.
|
|
void | notify_one () |
| | Resumes one task suspended waiting on this atomic_condition, if there is any.
|
|
void | notify_all () |
| | Resumes all tasks suspended waiting on this atomic_condition.
|
| std::atomic< T > & | atomic () noexcept |
| | Access to the internal atomic value.
|
| const std::atomic< T > & | atomic () const noexcept |
| | Access to the internal atomic value.
|
| std::atomic< T > & | operator* () noexcept |
| | Access to the internal atomic value.
|
| const std::atomic< T > & | operator* () const noexcept |
| | Access to the internal atomic value.
|
| std::atomic< T > * | operator-> () noexcept |
| | Access to the internal atomic value.
|
| const std::atomic< T > * | operator-> () const noexcept |
| | Access to the internal atomic value.
|
template<typename T>
class coopsync_tbb::atomic_condition< T >
Wrapper around std::atomic that provides atomic waiting which suspends the calling task instead of blocking it.
- Template Parameters
-
| T | The type of the value contained in the atomic_condition. Must be TriviallyCopyable, CopyConstructible and CopyAssignable. |
◆ atomic_condition()
Constructs a new atomic_condition with the given initial value. This operation is not atomic.
- Parameters
-
| value | A value to move-construct the internal atomic from. |
◆ ~atomic_condition()
Destroys the atomic_condition.
- Note
- The destructor must not be called while there are still tasks waiting on the atomic_condition. The destructor does not notify or resume any waiting tasks.
◆ atomic() [1/2]
Access to the internal atomic value.
- Returns
- Const reference to the internal atomic value. Remains valid for the lifetime of the atomic_condition.
◆ atomic() [2/2]
Access to the internal atomic value.
- Returns
- Reference to the internal atomic value. Remains valid for the lifetime of the atomic_condition.
◆ operator*() [1/2]
Access to the internal atomic value.
- Returns
- Const reference to the internal atomic value. Remains valid for the lifetime of the atomic_condition.
◆ operator*() [2/2]
Access to the internal atomic value.
- Returns
- Reference to the internal atomic value. Remains valid for the lifetime of the atomic_condition.
◆ operator->() [1/2]
Access to the internal atomic value.
- Returns
- Const pointer to the internal atomic value. Remains valid for the lifetime of the atomic_condition.
◆ operator->() [2/2]
Access to the internal atomic value.
- Returns
- Pointer to the internal atomic value. Remains valid for the lifetime of the atomic_condition.
◆ wait()
Suspends the calling task until the internal atomic value is not equal to specified value. If the internal atomic value is not equal to old, the function returns immediately. Otherwise, the task is suspended. The task will be resumed once notify_one or notify_all is called and the internal atomic value is not equal to old.
- Parameters
-
| old | The value to compare the internal atomic value to. The task will be suspended while the internal atomic value is equal to old. |
| order | The memory order to use for loading the internal atomic 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 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: