fixed testing

This commit is contained in:
john30
2017-08-27 16:46:41 +02:00
parent 4c93d1e2d5
commit 46f60e821c
6 changed files with 28 additions and 37 deletions
-21
View File
@@ -105,25 +105,4 @@ bool WaitThread::Wait(int seconds) {
return isRunning();
}
Mutex::Mutex() {
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&m_mutex, &attr);
pthread_mutexattr_destroy(&attr);
}
Mutex::~Mutex() {
pthread_mutex_destroy(&m_mutex);
}
void Mutex::lock() {
pthread_mutex_lock(&m_mutex);
}
void Mutex::unlock() {
pthread_mutex_unlock(&m_mutex);
}
} // namespace ebusd
+16 -4
View File
@@ -151,22 +151,34 @@ class Mutex {
/**
* Constructor.
*/
Mutex();
inline Mutex() {
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&m_mutex, &attr);
pthread_mutexattr_destroy(&attr);
}
/**
* Destructor.
*/
virtual ~Mutex();
virtual inline ~Mutex() {
pthread_mutex_destroy(&m_mutex);
};
/**
* Lock this mutex.
*/
void lock();
void inline lock() {
pthread_mutex_lock(&m_mutex);
}
/**
* Unlock this mutex.
*/
void unlock();
void inline unlock() {
pthread_mutex_unlock(&m_mutex);
}
private:
/** the mutex for waiting. */