fixed testing
This commit is contained in:
@@ -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
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user