TwoTerm/cpp/Lock.h
Kelvin Sherlock effa18a344 moving things around
git-svn-id: svn://qnap.local/TwoTerm/trunk@1987 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
2011-01-12 03:50:56 +00:00

32 lines
371 B
C++

#ifndef __LOCK_H__
#define __LOCK_H__
#include <pthread.h>
class Lock {
public:
Lock();
~Lock();
void lock();
void unlock();
bool tryLock();
private:
pthread_mutex_t _mutex;
};
class Locker {
public:
Locker(Lock& lock) : _lock(lock) { _lock.lock(); }
~Locker() { _lock.unlock(); }
private:
Lock &_lock;
};
#endif