Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
mpsc_queue_node.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_node.h
10//! @brief MpscQueue node.
11
12#ifndef ROC_CORE_MPSC_QUEUE_NODE_H_
13#define ROC_CORE_MPSC_QUEUE_NODE_H_
14
15#include "roc_core/atomic.h"
18#include "roc_core/panic.h"
19
20namespace roc {
21namespace core {
22
23//! MpscQueue node.
24class MpscQueueNode : public NonCopyable<MpscQueueNode> {
25public:
26 //! List node data.
28 //! Next list element.
30
31 //! Pointer to the containing queue.
32 void* queue;
33
35 : next(NULL)
36 , queue(NULL) {
37 }
38
39 //! Get MpscQueueNode object that contains this ListData object.
41 return ROC_CONTAINER_OF(this, MpscQueueNode, mpsc_queue_data_);
42 }
43 };
44
46 if (mpsc_queue_data_.queue) {
47 roc_panic("mpsc node: attempt to destroy node while it's still in queue");
48 }
49 }
50
51 //! Get list node data.
53 return &mpsc_queue_data_;
54 }
55
56private:
57 mutable MpscQueueData mpsc_queue_data_;
58};
59
60} // namespace core
61} // namespace roc
62
63#endif // ROC_CORE_MPSC_QUEUE_NODE_H_
Atomic.
MpscQueueData * mpsc_queue_data() const
Get list node data.
Base class for non-copyable objects.
Definition noncopyable.h:23
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Helper macros.
#define ROC_CONTAINER_OF(ptr, type, member)
Cast a member of a structure out to the containing structure.
Root namespace.
Non-copyable object.
Panic.
#define roc_panic(...)
Print error message and terminate program gracefully.
Definition panic.h:50
MpscQueueData * next
Next list element.
void * queue
Pointer to the containing queue.
MpscQueueNode * container_of()
Get MpscQueueNode object that contains this ListData object.