[APR-2053]wlbt: NAN R2 integration fxes
[GitHub/MotorolaMobilityLLC/hardware-samsung_slsi-scsc_wifibt-wifi_hal.git] / sync.h
CommitLineData
7753f181
DD
1
2#include <pthread.h>
3
4#ifndef __WIFI_HAL_SYNC_H__
5#define __WIFI_HAL_SYNC_H__
6
7class Mutex
8{
9private:
10 pthread_mutex_t mMutex;
11public:
12 Mutex() {
13 pthread_mutex_init(&mMutex, NULL);
14 }
15 ~Mutex() {
16 pthread_mutex_destroy(&mMutex);
17 }
18 int tryLock() {
19 return pthread_mutex_trylock(&mMutex);
20 }
21 int lock() {
22 return pthread_mutex_lock(&mMutex);
23 }
24 void unlock() {
25 pthread_mutex_unlock(&mMutex);
26 }
27};
28
29class Condition
30{
31private:
32 pthread_cond_t mCondition;
33 pthread_mutex_t mMutex;
34
35public:
36 Condition() {
37 pthread_mutex_init(&mMutex, NULL);
38 pthread_cond_init(&mCondition, NULL);
39 }
40 ~Condition() {
41 pthread_cond_destroy(&mCondition);
42 pthread_mutex_destroy(&mMutex);
43 }
44
45 int wait() {
46 return pthread_cond_wait(&mCondition, &mMutex);
47 }
48
49 void signal() {
50 pthread_cond_signal(&mCondition);
51 }
52};
53
b2737ea7 54#endif