2013-09-22 03:01:24 -03:00
|
|
|
|
|
|
|
#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() {
|
2013-09-27 21:00:49 -03:00
|
|
|
/* we need pthread semaphores here */
|
2013-09-22 03:01:24 -03:00
|
|
|
if (!_taken) {
|
|
|
|
_taken = true;
|
|
|
|
return true;
|
|
|
|
}
|
2013-09-27 21:00:49 -03:00
|
|
|
return false;
|
2013-09-22 03:01:24 -03:00
|
|
|
}
|