SpECTRE
v2025.03.17
|
A static capacity runtime-sized single-producer single-consumer lockfree queue. More...
#include <StaticSpscQueue.hpp>
Public Member Functions | |
StaticSpscQueue (const StaticSpscQueue &)=delete | |
StaticSpscQueue & | operator= (const StaticSpscQueue &)=delete |
StaticSpscQueue (StaticSpscQueue &&)=delete | |
StaticSpscQueue & | operator= (StaticSpscQueue &&)=delete |
template<typename... Args> | |
void | emplace (Args &&... args) noexcept(std::is_nothrow_constructible_v< T, Args &&... >) |
Construct a new element at the end of the queue in place. More... | |
template<typename... Args> | |
bool | try_emplace (Args &&... args) noexcept(std::is_nothrow_constructible_v< T, Args &&... >) |
Construct a new element at the end of the queue in place. More... | |
void | push (const T &v) noexcept(std::is_nothrow_copy_constructible_v< T >) |
Push a new element to the end of the queue. More... | |
template<typename P , Requires< std::is_constructible_v< T, P && > > = nullptr> | |
void | push (P &&v) noexcept(std::is_nothrow_constructible_v< T, P && >) |
Push a new element to the end of the queue. More... | |
bool | try_push (const T &v) noexcept(std::is_nothrow_copy_constructible_v< T >) |
Push a new element to the end of the queue. Returns false if the queue is at capacity and does not push the new object, otherwise returns true . More... | |
template<typename P , Requires< std::is_constructible_v< T, P && > > = nullptr> | |
bool | try_push (P &&v) noexcept(std::is_nothrow_constructible_v< T, P && >) |
Push a new element to the end of the queue. Returns false if the queue is at capacity and does not push the new object, otherwise returns true . More... | |
T * | front () noexcept |
Returns the first element from the queue. More... | |
void | pop () |
Removes the first element from the queue. | |
size_t | size () const noexcept |
Returns the size of the queue at a particular hardware state. More... | |
bool | empty () const noexcept |
Returns true if the queue may be empty, otherwise false . More... | |
size_t | capacity () const noexcept |
Returns the capacity of the queue. | |
A static capacity runtime-sized single-producer single-consumer lockfree queue.
As long as only one thread reads and writes simultaneously the queue is threadsafe. Which threads read and write can change throughout program execution, the important thing is that there is no instance during the execution where more than one thread tries to read and where more than one thread tries to write.
|
inlinenoexcept |
Construct a new element at the end of the queue in place.
Uses placement new for in-place construction.
capacity()
is exceeded without warning.
|
inlinenoexcept |
Returns true
if the queue may be empty, otherwise false
.
Note that while this can be checked in a threadsafe manner, it is up to the user to guarantee that another thread does not change the queue between when empty()
is called and how the result is used.
|
inlinenoexcept |
Returns the first element from the queue.
nullptr
if the queue is empty.
|
inlinenoexcept |
Push a new element to the end of the queue.
Uses emplace()
internally.
capacity()
is exceeded without warning.
|
inlinenoexcept |
Push a new element to the end of the queue.
Uses emplace()
internally.
capacity()
is exceeded without warning.
|
inlinenoexcept |
Returns the size of the queue at a particular hardware state.
Note that while this can be checked in a threadsafe manner, it is up to the user to guarantee that another thread does not change the queue between when size()
is called and how the result is used.
|
inlinenoexcept |
Construct a new element at the end of the queue in place.
Uses placement new for in-place construction.
Returns true
if the emplacement succeeded and false
if it did not. If it failed then the queue is currently full.
|
inlinenoexcept |
Push a new element to the end of the queue. Returns false
if the queue is at capacity and does not push the new object, otherwise returns true
.
Uses try_emplace()
internally.
|
inlinenoexcept |
Push a new element to the end of the queue. Returns false
if the queue is at capacity and does not push the new object, otherwise returns true
.
Uses try_emplace()
internally.