Arduino STK 4.6.2
Mutex.h
1
2#ifndef STK_MUTEX_H
3#define STK_MUTEX_H
4
5#include "Stk.h"
6
7#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
8 #include <pthread.h>
9 typedef pthread_mutex_t MUTEX;
10 typedef pthread_cond_t CONDITION;
11 #define STK_MUTEXT_SUPPORTED
12
13#elif defined(__OS_WINDOWS__)
14
15 #include <windows.h>
16 #include <process.h>
17 typedef CRITICAL_SECTION MUTEX;
18 typedef HANDLE CONDITION;
19 #define STK_MUTEXT_SUPPORTED
20
21// Commented out to support ESP32 C3
22// #elif defined(__RTOS__)
23// #include <freertos/FreeRTOS.h>
24// #include <freertos/semphr.h>
25// typedef SemaphoreHandle_t MUTEX;
26// typedef SemaphoreHandle_t* CONDITION;
27// #define STK_MUTEXT_SUPPORTED
28
29#endif
30
31#ifdef STK_MUTEXT_SUPPORTED
32
33namespace stk {
34
35/***************************************************/
46/***************************************************/
47
48class Mutex : public Stk
49{
50 public:
53
56
58 void lock(void);
59
61 void unlock(void);
62
64
68 void wait(void);
69
71
75 void signal(void);
76
77 protected:
78
79 MUTEX mutex_;
80 CONDITION condition_;
81
82};
83
84} // stk namespace
85
86#endif
87#endif
88
~Mutex()
Class destructor.
Mutex()
Default constructor.
void signal(void)
Signal the condition variable.
void unlock(void)
Unlock the mutex.
void lock(void)
Lock the mutex.
void wait(void)
Wait indefinitely on the mutex condition variable.
Stk(void)
Default constructor.
The STK namespace.
Definition ADSR.h:8