Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
mpsc_queue_impl.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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_core/mpsc_queue_impl.h
10 //! @brief Multi-producer single-consumer queue internal implementation.
11 
12 #ifndef ROC_CORE_MPSC_QUEUE_IMPL_H_
13 #define ROC_CORE_MPSC_QUEUE_IMPL_H_
14 
16 
17 namespace roc {
18 namespace core {
19 
20 //! Multi-producer single-consumer queue internal implementation class.
21 //!
22 //! Provides only push/pop functionality. Ownership is left up to the main MpscQueue
23 //! class.
25 public:
26  MpscQueueImpl();
27 
28  ~MpscQueueImpl();
29 
30  //! Add object to the end of the queue.
32 
33  //! Remove object from the beginning of the queue.
35 
36 private:
38 
39  void push_node_(MpscQueueData* node);
40  MpscQueueData* pop_node_(bool can_spin);
41 
42  MpscQueueData* wait_next_(MpscQueueData* node);
43  MpscQueueData* try_wait_next_(MpscQueueData* node);
44 
45  void change_owner_(MpscQueueData* node, void* from, void* to);
46 
47  MpscQueueData* tail_;
48  MpscQueueData* head_;
49 
50  MpscQueueData stub_;
51 };
52 
53 } // namespace core
54 } // namespace roc
55 
56 #endif // ROC_CORE_MPSC_QUEUE_IMPL_H_
Multi-producer single-consumer queue internal implementation class.
void push_back(MpscQueueNode::MpscQueueData *node)
Add object to the end of the queue.
MpscQueueNode::MpscQueueData * pop_front(bool can_spin)
Remove object from the beginning of the queue.
MpscQueue node.
Root namespace.