Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
concurrent_queue.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Roc Streaming 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/concurrent_queue.h
10//! @brief Concurrent blocking packet queue.
11
12#ifndef ROC_PACKET_CONCURRENT_QUEUE_H_
13#define ROC_PACKET_CONCURRENT_QUEUE_H_
14
15#include "roc_core/cond.h"
16#include "roc_core/list.h"
17#include "roc_core/mutex.h"
19#include "roc_packet/ireader.h"
20#include "roc_packet/iwriter.h"
21#include "roc_packet/packet.h"
22
23namespace roc {
24namespace packet {
25
26//! Concurrent blocking packet queue.
27class ConcurrentQueue : public IReader, public IWriter, public core::NonCopyable<> {
28public:
30
31 //! Read next packet.
32 //! @remarks
33 //! Blocks until the queue becomes non-empty and returns the first
34 //! packet from the queue.
35 virtual PacketPtr read();
36
37 //! Add packet to the queue.
38 //! @remarks
39 //! Adds packet to the end of the queue.
40 virtual void write(const PacketPtr& packet);
41
42private:
43 core::Mutex mutex_;
44 core::Cond cond_;
46};
47
48} // namespace packet
49} // namespace roc
50
51#endif // ROC_PACKET_CONCURRENT_QUEUE_H_
Condition variable.
Definition: cond.h:27
Intrusive doubly-linked list.
Definition: list.h:35
Mutex.
Definition: mutex.h:30
Base class for non-copyable objects.
Definition: noncopyable.h:23
Concurrent blocking packet queue.
virtual PacketPtr read()
Read next packet.
virtual void write(const PacketPtr &packet)
Add packet to the queue.
Packet reader interface.
Definition: ireader.h:21
Packet writer interface.
Definition: iwriter.h:21
Condition variable.
Packet reader interface.
Packet writer interface.
Intrusive doubly-linked list.
Mutex.
Root namespace.
Non-copyable object.
Packet.