mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2024-12-22 22:29:51 +00:00
effa18a344
git-svn-id: svn://qnap.local/TwoTerm/trunk@1987 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
32 lines
371 B
C++
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
|