Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
queue.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Roc authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_packet/queue.h
10 //! @brief Packet queue.
11 
12 #ifndef ROC_PACKET_QUEUE_H_
13 #define ROC_PACKET_QUEUE_H_
14 
15 #include "roc_core/list.h"
16 #include "roc_core/noncopyable.h"
17 #include "roc_packet/ireader.h"
18 #include "roc_packet/iwriter.h"
19 #include "roc_packet/packet.h"
20 
21 namespace roc {
22 namespace packet {
23 
24 //! Packet queue.
25 class Queue : public IReader, public IWriter, public core::NonCopyable<> {
26 public:
27  //! Read next packet.
28  //! @returns
29  //! the first packet in the queue or null if there are no packets.
30  virtual PacketPtr read();
31 
32  //! Add packet to the queue.
33  //! @remarks
34  //! Adds packet to the end of the queue.
35  virtual void write(const PacketPtr& packet);
36 
37  //! Get number of packets in queue.
38  size_t size() const;
39 
40 private:
41  core::List<Packet> list_;
42 };
43 
44 } // namespace packet
45 } // namespace roc
46 
47 #endif // ROC_PACKET_QUEUE_H_
virtual PacketPtr read()
Read next packet.
Packet queue.
Definition: queue.h:25
Packet reader interface.
Packet reader interface.
Definition: ireader.h:21
Root namespace.
Intrusive doubly-linked list.
Definition: list.h:31
size_t size() const
Get number of packets in queue.
virtual void write(const PacketPtr &packet)
Add packet to the queue.
Packet writer interface.
Packet writer interface.
Definition: iwriter.h:21
Intrusive doubly-linked list.
Base class for non-copyable objects.
Definition: noncopyable.h:23
Packet.
Non-copyable object.