ardupilot/libraries/AP_HAL_Empty/Semaphore.cpp
Andrew Tridgell a3c26d44e4 AP_HAL: rename Sempahore.h to Semaphores.h
this is needed to allow build on MacOS, as its case-insensitive
filesystem picks up the NuttX semaphore.h
2013-01-02 18:22:13 +11:00

41 lines
719 B
C++

#include "Semaphores.h"
using namespace Empty;
EmptySemaphore::EmptySemaphore() :
_owner(NULL),
_k(NULL)
{}
bool EmptySemaphore::get(void* owner) {
if (_owner == NULL) {
_owner = owner;
return true;
} else {
return false;
}
}
bool EmptySemaphore::release(void* owner) {
if (_owner == NULL || _owner != owner) {
return false;
} else {
_owner = NULL;
if (_k){
_k();
_k = NULL;
}
return true;
}
}
bool EmptySemaphore::call_on_release(void* caller, AP_HAL::Proc k) {
/* idk what semantics randy was looking for here, honestly.
* seems like a bad idea. */
_k = k;
return true;
}