mirror of
https://github.com/ksherlock/profuse.git
synced 2024-12-22 20:29:59 +00:00
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
|