mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-08 08:58:29 -04:00
58a31318ee
this works sufficiently for the HMC5883
27 lines
443 B
C++
27 lines
443 B
C++
|
|
#include "Semaphores.h"
|
|
|
|
using namespace Linux;
|
|
|
|
bool LinuxSemaphore::give() {
|
|
if (_taken) {
|
|
_taken = false;
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool LinuxSemaphore::take(uint32_t timeout_ms) {
|
|
return take_nonblocking();
|
|
}
|
|
|
|
bool LinuxSemaphore::take_nonblocking() {
|
|
/* we need pthread semaphores here */
|
|
if (!_taken) {
|
|
_taken = true;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|