arduino-audio-tools
Loading...
Searching...
No Matches
SynchronizedQueue.h
Go to the documentation of this file.
1#pragma once
3
4namespace audio_tools {
5
15template <class T, class TMutex>
17 public:
18 SynchronizedQueue() = default;
19
20 bool enqueue(T& data) {
22 return l.push_front(data);
23 }
24
25 bool peek(T& data) {
27 if (l.end()->prior == nullptr) return false;
28 data = *(l.end()->prior);
29 return true;
30 }
31
32 bool dequeue(T& data) {
34 return l.pop_back(data);
35 }
36
37 size_t size() {
39 return l.size();
40 }
41
42 bool clear() {
44 return l.clear();
45 }
46
47 bool empty() {
49 return l.empty();
50 }
51
52 void setAllocator(Allocator& allocator) { l.setAllocator(allocator); }
53
54 protected:
57};
58
59} // namespace audio_tools
Memory allocateator which uses malloc.
Definition Allocator.h:23
Double linked list.
Definition List.h:18
RAII implementaion using a Mutex: Only a few microcontrollers provide lock guards,...
Definition LockGuard.h:17
FIFO Queue which is based on a List that is thread save.
Definition SynchronizedQueue.h:16
size_t size()
Definition SynchronizedQueue.h:37
bool empty()
Definition SynchronizedQueue.h:47
bool peek(T &data)
Definition SynchronizedQueue.h:25
bool dequeue(T &data)
Definition SynchronizedQueue.h:32
bool clear()
Definition SynchronizedQueue.h:42
TMutex mutex
Definition SynchronizedQueue.h:56
bool enqueue(T &data)
Definition SynchronizedQueue.h:20
void setAllocator(Allocator &allocator)
Definition SynchronizedQueue.h:52
List< T > l
Definition SynchronizedQueue.h:55
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
size_t writeData(Print *p_out, T *data, int samples, int maxSamples=512)
Definition AudioTypes.h:512