You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
758 B

14 years ago
#ifndef MUTEX_HPP
#define MUTEX_HPP
#include <pthread.h>
class Mutex
{
14 years ago
public:
Mutex(int kind = PTHREAD_MUTEX_DEFAULT);
~Mutex();
/**
* Locks mutex. If already locked, the calling thread shall block until
* the mutex becomes available.
* @returns If successful, zero; otherwise, an error number.
*/
int lock();
/**
*
*/
int unlock();
/**
* If currently locked, the call shall return immediately.
* @returns Zero if a lock acquired. Otherwise, an error number.
*/
int tryLock(const long int intervalSec = 0, const long int intervalNSec = 0);
pthread_mutex_t* getPThreadMutex();
14 years ago
14 years ago
private:
Mutex(const Mutex& m);
Mutex& operator=(const Mutex& m);
pthread_mutex_t m_mutex;
14 years ago
};
#endif // MUTEX_HPP