mirror of
https://github.com/ksherlock/profuse.git
synced 2024-12-25 08:29:22 +00:00
28 lines
367 B
C++
28 lines
367 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 |