Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::packet::SortedQueue Class Reference

Sorted packet queue. More...

#include <sorted_queue.h>

Inheritance diagram for roc::packet::SortedQueue:
Collaboration diagram for roc::packet::SortedQueue:

Public Member Functions

 SortedQueue (size_t max_size)
 Construct empty queue. More...
 
virtual ROC_ATTR_NODISCARD status::StatusCode write (const PacketPtr &packet)
 Add packet to the queue. More...
 
virtual ROC_ATTR_NODISCARD status::StatusCode read (PacketPtr &packet)
 Read next packet. More...
 
size_t size () const
 Get number of packets in queue. More...
 
PacketPtr head () const
 Get first packet in the queue. More...
 
PacketPtr tail () const
 Get last packet in the queue. More...
 
PacketPtr latest () const
 Get the latest packet that were ever added to the queue. More...
 

Detailed Description

Sorted packet queue.

Remarks
Packets order is determined by Packet::compare() method.

Definition at line 27 of file sorted_queue.h.

Constructor & Destructor Documentation

◆ SortedQueue()

roc::packet::SortedQueue::SortedQueue ( size_t  max_size)
explicit

Construct empty queue.

Remarks
If max_size is non-zero, it specifies maximum number of packets in queue.

Member Function Documentation

◆ head()

PacketPtr roc::packet::SortedQueue::head ( ) const

Get first packet in the queue.

Returns
the first packet in the queue or null if there are no packets
Remarks
Returned packet is not removed from the queue.

◆ latest()

PacketPtr roc::packet::SortedQueue::latest ( ) const

Get the latest packet that were ever added to the queue.

Remarks
Returns null if the queue never has any packets. Otherwise, returns the latest ever added packet, even if that packet is not currently in the queue. Returned packet is not removed from the queue.

◆ read()

virtual ROC_ATTR_NODISCARD status::StatusCode roc::packet::SortedQueue::read ( PacketPtr packet)
virtual

Read next packet.

Remarks
Removes returned packet from the queue.

Implements roc::packet::IReader.

◆ size()

size_t roc::packet::SortedQueue::size ( ) const

Get number of packets in queue.

◆ tail()

PacketPtr roc::packet::SortedQueue::tail ( ) const

Get last packet in the queue.

Returns
the last packet in the queue or null if there are no packets
Remarks
Returned packet is not removed from the queue.

◆ write()

virtual ROC_ATTR_NODISCARD status::StatusCode roc::packet::SortedQueue::write ( const PacketPtr packet)
virtual

Add packet to the queue.

Remarks
  • if the maximum queue size is reached, packet is dropped
  • if packet is equal to another packet in the queue, it is dropped
  • otherwise, packet is inserted into the queue, keeping the queue sorted

Implements roc::packet::IWriter.


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