MySQL 8.0.39
Source Code Documentation
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator Class Reference

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
 
Iteratoroperator= (const Iterator &rhs)
 
Iteratoroperator= (Iterator &&rhs)
 
Iteratoroperator++ ()
 
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...
 

Detailed Description

template<typename T, T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
class container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator

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.

Member Typedef Documentation

◆ difference_type

template<typename T , T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::difference_type = std::ptrdiff_t

◆ iterator_category

template<typename T , T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::iterator_category = std::forward_iterator_tag

◆ pointer

template<typename T , T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::pointer = T *

◆ reference

template<typename T , T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::reference = T

◆ value_type

template<typename T , T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
using container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::value_type = T

Constructor & Destructor Documentation

◆ Iterator() [1/3]

template<typename T , T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::Iterator ( Integrals_lockfree_queue< T, Null, Erased, I, A > const &  parent,
index_type  position 
)
explicit

◆ Iterator() [2/3]

template<typename T , T Null, T Erased, typename I , typename A >
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::Iterator ( const Iterator rhs)

◆ Iterator() [3/3]

template<typename T , T Null, T Erased, typename I , typename A >
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::Iterator ( Iterator &&  rhs)

◆ ~Iterator()

template<typename T , T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
virtual container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::~Iterator ( )
virtualdefault

Member Function Documentation

◆ operator!=()

template<typename T , T Null, T Erased, typename I , typename A >
bool container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator!= ( Iterator const &  rhs) const

◆ operator*()

template<typename T , T Null, T Erased, typename I , typename A >
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::reference container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator*

◆ operator++() [1/2]

template<typename T , T Null, T Erased, typename I , typename A >
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator & container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator++

◆ operator++() [2/2]

template<typename T , T Null, T Erased, typename I , typename A >
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator++ ( int  )

◆ operator->()

template<typename T , T Null, T Erased, typename I , typename A >
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::pointer container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator->

◆ operator=() [1/2]

template<typename T , T Null, T Erased, typename I , typename A >
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator & container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator= ( const Iterator rhs)

◆ operator=() [2/2]

template<typename T , T Null, T Erased, typename I , typename A >
container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator & container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator= ( Iterator &&  rhs)

◆ operator==()

template<typename T , T Null, T Erased, typename I , typename A >
bool container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::operator== ( Iterator const &  rhs) const

◆ set()

template<typename T , T Null, T Erased, typename I , typename A >
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.

Parameters
new_valueThe new value to set the element to.

Member Data Documentation

◆ m_current

template<typename T , T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
index_type container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::m_current {std::numeric_limits<index_type>::max()}
private

The position of the element this iterator is pointing to.

◆ m_parent

template<typename T , T Null = std::numeric_limits<T>::max(), T Erased = Null, typename I = container::Padded_indexing<T>, typename A = std::nullptr_t>
Integrals_lockfree_queue<T, Null, Erased, I, A> const* container::Integrals_lockfree_queue< T, Null, Erased, I, A >::Iterator::m_parent {nullptr}
private

The reference to the queue holding the elements.


The documentation for this class was generated from the following file: