mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-10 13:37:03 +03:00
big merge
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#ifndef UNIXLIKE_WRAPPED_MUTEX_H
|
||||
#define UNIXLIKE_WRAPPED_MUTEX_H
|
||||
#include <pthread.h>
|
||||
|
||||
/**
|
||||
* Wraps a mutex on unixlike patforms (linux, macOS, esp32 etc.).
|
||||
* Header only since all the methods call one function, we want them to be inlined
|
||||
**/
|
||||
class WrappedMutex
|
||||
{
|
||||
public:
|
||||
WrappedMutex()
|
||||
{
|
||||
pthread_mutex_init(&this->_mutex, NULL);
|
||||
}
|
||||
|
||||
~WrappedMutex()
|
||||
{
|
||||
pthread_mutex_destroy(&this->_mutex);
|
||||
}
|
||||
|
||||
void lock()
|
||||
{
|
||||
pthread_mutex_lock(&this->_mutex);
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
pthread_mutex_unlock(&this->_mutex);
|
||||
}
|
||||
|
||||
private:
|
||||
pthread_mutex_t _mutex;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user