-\r
-#include <pthread.h>\r
-\r
-#ifndef __WIFI_HAL_SYNC_H__\r
-#define __WIFI_HAL_SYNC_H__\r
-\r
-class Mutex\r
-{\r
-private:\r
- pthread_mutex_t mMutex;\r
-public:\r
- Mutex() {\r
- pthread_mutex_init(&mMutex, NULL);\r
- }\r
- ~Mutex() {\r
- pthread_mutex_destroy(&mMutex);\r
- }\r
- int tryLock() {\r
- return pthread_mutex_trylock(&mMutex);\r
- }\r
- int lock() {\r
- return pthread_mutex_lock(&mMutex);\r
- }\r
- void unlock() {\r
- pthread_mutex_unlock(&mMutex);\r
- }\r
-};\r
-\r
-class Condition\r
-{\r
-private:\r
- pthread_cond_t mCondition;\r
- pthread_mutex_t mMutex;\r
-\r
-public:\r
- Condition() {\r
- pthread_mutex_init(&mMutex, NULL);\r
- pthread_cond_init(&mCondition, NULL);\r
- }\r
- ~Condition() {\r
- pthread_cond_destroy(&mCondition);\r
- pthread_mutex_destroy(&mMutex);\r
- }\r
-\r
- int wait() {\r
- return pthread_cond_wait(&mCondition, &mMutex);\r
- }\r
-\r
- void signal() {\r
- pthread_cond_signal(&mCondition);\r
- }\r
-};\r
-\r
+
+#include <pthread.h>
+
+#ifndef __WIFI_HAL_SYNC_H__
+#define __WIFI_HAL_SYNC_H__
+
+class Mutex
+{
+private:
+ pthread_mutex_t mMutex;
+public:
+ Mutex() {
+ pthread_mutex_init(&mMutex, NULL);
+ }
+ ~Mutex() {
+ pthread_mutex_destroy(&mMutex);
+ }
+ int tryLock() {
+ return pthread_mutex_trylock(&mMutex);
+ }
+ int lock() {
+ return pthread_mutex_lock(&mMutex);
+ }
+ void unlock() {
+ pthread_mutex_unlock(&mMutex);
+ }
+};
+
+class Condition
+{
+private:
+ pthread_cond_t mCondition;
+ pthread_mutex_t mMutex;
+
+public:
+ Condition() {
+ pthread_mutex_init(&mMutex, NULL);
+ pthread_cond_init(&mCondition, NULL);
+ }
+ ~Condition() {
+ pthread_cond_destroy(&mCondition);
+ pthread_mutex_destroy(&mMutex);
+ }
+
+ int wait() {
+ return pthread_cond_wait(&mCondition, &mMutex);
+ }
+
+ void signal() {
+ pthread_cond_signal(&mCondition);
+ }
+};
+
#endif
\ No newline at end of file