Line data Source code
1 : #pragma once 2 : 3 : /// Mutex that doesn't lock anything, used on single-core systems. 4 : struct EmptyMutex { 5 : void lock() { /* nothing */ } 6 : void unlock() { /* nothing */ } 7 : }; 8 : 9 : /// Lock guard that doesn't lock it's mutex, used on single-core systems. 10 : template <class Mutex> 11 : struct EmptyLockGuard { 12 490 : EmptyLockGuard(Mutex &) { /* nothing */ } 13 490 : ~EmptyLockGuard() { /* nothing */ } 14 : }; 15 : 16 : #if defined(ESP32) || !defined(ARDUINO) 17 : 18 : #include <mutex> 19 : 20 : using DefaultMutEx = std::mutex; 21 : template <class Mutex> 22 : using DefaultLockGuard = std::lock_guard<Mutex>; 23 : 24 : #else 25 : 26 : using DefaultMutEx = EmptyMutex; 27 : template <class Mutex> 28 : using DefaultLockGuard = EmptyLockGuard<Mutex>; 29 : 30 : #endif