arduino-audio-tools
Loading...
Searching...
No Matches
SynchronizedQueue.h
1#pragma once
2#include "AudioTools/CoreAudio/AudioBasic/Collections/List.h"
3
4namespace audio_tools {
5
15template <class T, class TMutex>
17 public:
18 SynchronizedQueue() = default;
19
20 bool enqueue(T& data) {
21 LockGuard guard{mutex};;
22 return l.push_front(data);
23 }
24
25 bool peek(T& data) {
26 LockGuard guard{mutex};;
27 if (l.end()->prior == nullptr) return false;
28 data = *(l.end()->prior);
29 return true;
30 }
31
32 bool dequeue(T& data) {
33 LockGuard guard{mutex};;
34 return l.pop_back(data);
35 }
36
37 size_t size() {
38 LockGuard guard{mutex};;
39 return l.size();
40 }
41
42 bool clear() {
43 LockGuard guard{mutex};;
44 return l.clear();
45 }
46
47 bool empty() {
48 LockGuard guard{mutex};;
49 return l.empty();
50 }
51
52 void setAllocator(Allocator& allocator) { l.setAllocator(allocator); }
53
54 protected:
55 List<T> l;
56 TMutex mutex;
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
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy