arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
LockGuard.h
1#pragma once
2#include "AudioToolsConfig.h"
3#include "Mutex.h"
4
5namespace audio_tools {
6
17class LockGuard {
18 public:
19 LockGuard(MutexBase &mutex) {
20 p_mutex = &mutex;
21 p_mutex->lock();
22 }
23
24 LockGuard(MutexBase *mutex) {
25 p_mutex = mutex;
26 if (p_mutex != nullptr) p_mutex->lock();
27 }
28
29 ~LockGuard() {
30 if (p_mutex != nullptr) p_mutex->unlock();
31 }
32
33 protected:
34 MutexBase *p_mutex = nullptr;
35};
36
37} // namespace audio_tools
RAII implementaion using a Mutex: Only a few microcontrollers provide lock guards,...
Definition LockGuard.h:17
Empty Mutex implementation which does nothing.
Definition Mutex.h:18
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10