rsl 1.1.0
ROS Support Library
Loading...
Searching...
No Matches
rsl::Queue< T > Class Template Reference

Thread-safe queue. Particularly useful when multiple threads need to write to and/or read from a queue. More...

#include <queue.hpp>

Public Member Functions

auto size () const noexcept
 Get the size of the queue.
 
auto empty () const noexcept
 Check if the queue is empty.
 
void push (T value) noexcept
 Push data into the queue.
 
void clear () noexcept
 Clear the queue.
 
auto pop (std::chrono::nanoseconds wait_time={}) -> std::optional< T >
 Wait for given duration then pop from the queue and return the element.
 

Detailed Description

template<typename T>
class rsl::Queue< T >

Thread-safe queue. Particularly useful when multiple threads need to write to and/or read from a queue.

Member Function Documentation

◆ empty()

template<typename T >
auto rsl::Queue< T >::empty ( ) const
inlinenoexcept

Check if the queue is empty.

Returns
True if the queue is empty, otherwise false

◆ pop()

template<typename T >
auto rsl::Queue< T >::pop ( std::chrono::nanoseconds  wait_time = {}) -> std::optional<T>
inline

Wait for given duration then pop from the queue and return the element.

Parameters
wait_timeMaximum time to wait for queue to be non-empty
Returns
Data popped from the queue or error

◆ push()

template<typename T >
void rsl::Queue< T >::push ( value)
inlinenoexcept

Push data into the queue.

Parameters
valueData to push into the queue

◆ size()

template<typename T >
auto rsl::Queue< T >::size ( ) const
inlinenoexcept

Get the size of the queue.

Returns
Queue size

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