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 #elif defined(__RTOS__)
22 
23  #include <freertos/FreeRTOS.h>
24  #include <freertos/semphr.h>
25 
26  typedef SemaphoreHandle_t MUTEX;
27  typedef SemaphoreHandle_t* CONDITION;
28  #define STK_MUTEXT_SUPPORTED
29 
30 
31 #endif
32 
33 #ifdef STK_MUTEXT_SUPPORTED
34 
35 namespace stk {
36 
37 /***************************************************/
48 /***************************************************/
49 
50 class Mutex : public Stk
51 {
52  public:
54  Mutex();
55 
57  ~Mutex();
58 
60  void lock(void);
61 
63  void unlock(void);
64 
66 
70  void wait(void);
71 
73 
77  void signal(void);
78 
79  protected:
80 
81  MUTEX mutex_;
82  CONDITION condition_;
83 
84 };
85 
86 } // stk namespace
87 
88 #endif
89 #endif
90 
STK mutex class.
Definition: Mutex.h:51
~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 base class.
Definition: Stk.h:144
The STK namespace.
Definition: ADSR.h:8