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 void write (const PacketPtr &packet)
 Add packet to the queue. More...
 
virtual PacketPtr read ()
 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

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

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.
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.
virtual PacketPtr roc::packet::SortedQueue::read ( )
virtual

Read next packet.

Returns
the first packet in the queue or null if there are no packets
Remarks
Removes returned packet from the queue.

Implements roc::packet::IReader.

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

Get number of packets in queue.

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.
virtual void 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: