mirror of
https://github.com/ksherlock/profuse.git
synced 2025-02-09 18:31:29 +00:00
git-svn-id: https://profuse.googlecode.com/svn/branches/v2@388 aa027e90-d47c-11dd-86d7-074df07e0730
31 lines
370 B
C++
31 lines
370 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
|