AERA
Public Member Functions | List of all members
tcp_io_device::SafeQueue Class Reference

#include <tcp_connection.h>

Public Member Functions

 SafeQueue ()
 
 SafeQueue (int max_elements)
 
void enqueue (std::unique_ptr< TCPMessage > t)
 
std::unique_ptr< TCPMessagedequeue ()
 
void clear ()
 

Detailed Description

SafeQueue is a thread-safe queue used to pass data from the TcpIoDevice to the TCPConnection for outgoing and the other way around for incoming messages.

Definition at line 82 of file tcp_connection.h.

Constructor & Destructor Documentation

◆ SafeQueue() [1/2]

tcp_io_device::SafeQueue::SafeQueue ( )
inline

Constructor with the name of the queue. Defaults the max number of messages in the queue to 1.

Definition at line 88 of file tcp_connection.h.

◆ SafeQueue() [2/2]

tcp_io_device::SafeQueue::SafeQueue ( int  max_elements)
inline

Constructor with the name of the queue. Sets the max number of messages in the queue accordingly.

Parameters
max_elementsThe max number of messages in the queue before old messages are deleted if a new one is enqueued.

Definition at line 99 of file tcp_connection.h.

Member Function Documentation

◆ clear()

void tcp_io_device::SafeQueue::clear ( )
inline

Clears all entries of the queue.

Definition at line 144 of file tcp_connection.h.

◆ dequeue()

std::unique_ptr<TCPMessage> tcp_io_device::SafeQueue::dequeue ( )
inline

Returns the front element (oldest) of the queue and deletes it.

Returns
Oldest message in the queue.

Definition at line 130 of file tcp_connection.h.

◆ enqueue()

void tcp_io_device::SafeQueue::enqueue ( std::unique_ptr< TCPMessage t)
inline

Adds a new element to the queue, also deletes old messages, if the number of messages in the queue is >= max_elements.

Parameters
tThe message to enqueue.

Definition at line 113 of file tcp_connection.h.


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