mirror of
https://github.com/ksherlock/profuse.git
synced 2025-01-10 23:29:42 +00:00
ea0d1c198b
git-svn-id: https://profuse.googlecode.com/svn/branches/profuse_interim@335 aa027e90-d47c-11dd-86d7-074df07e0730
34 lines
393 B
C++
34 lines
393 B
C++
#ifndef __LOCK_H__
|
|
#define __LOCK_H__
|
|
|
|
#include <pthread.h>
|
|
|
|
namespace ProFUSE {
|
|
|
|
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
|