MySQL 8.0.40
Source Code Documentation
|
Iterator helper class to iterate over the queue staring at the virtual index pointed to by the head, up until the virtual index pointed to by the tail. More...
#include <integrals_lockfree_queue.h>
Public Types | |
using | difference_type = std::ptrdiff_t |
using | value_type = T |
using | pointer = T * |
using | reference = T |
using | iterator_category = std::forward_iterator_tag |
Public Member Functions | |
Iterator (Integrals_lockfree_queue< T, Null, Erased, I, A > const &parent, index_type position) | |
Iterator (const Iterator &rhs) | |
Iterator (Iterator &&rhs) | |
virtual | ~Iterator ()=default |
Iterator & | operator= (const Iterator &rhs) |
Iterator & | operator= (Iterator &&rhs) |
Iterator & | operator++ () |
reference | operator* () const |
Iterator | operator++ (int) |
pointer | operator-> () const |
bool | operator== (Iterator const &rhs) const |
bool | operator!= (Iterator const &rhs) const |
void | set (value_type new_value) |
Sets the value of the element the iterator is pointing to the given parameter. More... | |
Private Attributes | |
index_type | m_current {std::numeric_limits<index_type>::max()} |
The position of the element this iterator is pointing to. More... | |
Integrals_lockfree_queue< T, Null, Erased, I, A > const * | m_parent {nullptr} |
The reference to the queue holding the elements. More... | |
Iterator helper class to iterate over the queue staring at the virtual index pointed to by the head, up until the virtual index pointed to by the tail.
Being an iterator over a lock-free structure, it will not be invalidated upon queue changes since operations are thread-safe and no invalid memory access should stem from iterating over and changing the queue, simultaneously.
However, the following possible iteration scenarios, not common in non-thread-safe structures, should be taken into consideration and analysed while using standard library features that use the Iterator
requirement, like for_each
loops, std::find
, std::find_if
, etc:
a) The iteration never stops because there is always an element being pushed before the queue end()
method is invoked.
b) The iterator points to Null
values at the beginning of the iteration because elements were popped just after the queue begin()
method is invoked.
c) The iterator points to Null
or Erased
in between pointing to values different from Null
or Erased
.
d) The iterator may point to values that do not correspond to the virtual index being held by the iterator, in the case of the amount of both pop and push operations between two iteration loops was higher then the queue capacity()
.
If one of the above scenarios is harmful to your use-case, an additional serialization mechanism may be needed to iterate over the queue. Or another type of structure may be more adequate.
Check C++ documentation for the definition of Iterator
named requirement for more information.
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::difference_type = std::ptrdiff_t |
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::iterator_category = std::forward_iterator_tag |
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::pointer = T * |
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::reference = T |
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::value_type = T |
|
explicit |
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::Iterator | ( | const Iterator & | rhs | ) |
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::Iterator | ( | Iterator && | rhs | ) |
|
virtualdefault |
bool container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator!= | ( | Iterator const & | rhs | ) | const |
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::reference container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator* |
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator & container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator++ |
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator++ | ( | int | ) |
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::pointer container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator-> |
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator & container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator= | ( | const Iterator & | rhs | ) |
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator & container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator= | ( | Iterator && | rhs | ) |
bool container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator== | ( | Iterator const & | rhs | ) | const |
void container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::set | ( | value_type | new_value | ) |
Sets the value of the element the iterator is pointing to the given parameter.
new_value | The new value to set the element to. |
|
private |
The position of the element this iterator is pointing to.
|
private |
The reference to the queue holding the elements.