mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2024-12-22 07:30:40 +00:00
39 lines
575 B
C
39 lines
575 B
C
|
/*
|
||
|
* Benaphore.h
|
||
|
* Blue Box
|
||
|
*
|
||
|
* Created by Kelvin Sherlock on 11/29/2009.
|
||
|
* Copyright 2009 Kelvin W Sherlock LLC. All rights reserved.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#ifndef __BENAPHORE_H__
|
||
|
#define __BENAPHORE_H__
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include <mach/semaphore.h>
|
||
|
|
||
|
|
||
|
class Benaphore {
|
||
|
public:
|
||
|
Benaphore();
|
||
|
~Benaphore();
|
||
|
|
||
|
void lock();
|
||
|
void unlock();
|
||
|
private:
|
||
|
int32_t _atom;
|
||
|
semaphore_t _sem;
|
||
|
|
||
|
};
|
||
|
|
||
|
class Locker {
|
||
|
public:
|
||
|
Locker(Benaphore& lock) : _lock(lock) { _lock.lock(); }
|
||
|
~Locker() { _lock.unlock(); }
|
||
|
|
||
|
private:
|
||
|
Benaphore& _lock;
|
||
|
};
|
||
|
|
||
|
#endif
|