2012-12-17 15:07:26 -04:00
|
|
|
|
2013-01-02 03:22:07 -04:00
|
|
|
#include "Semaphores.h"
|
2012-12-17 15:07:26 -04:00
|
|
|
|
|
|
|
using namespace Empty;
|
|
|
|
|
2013-01-02 20:44:23 -04:00
|
|
|
bool EmptySemaphore::give() {
|
|
|
|
if (_taken) {
|
|
|
|
_taken = false;
|
2012-12-17 15:07:26 -04:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-02 20:44:23 -04:00
|
|
|
bool EmptySemaphore::take(uint32_t timeout_ms) {
|
|
|
|
return take_nonblocking();
|
2012-12-17 15:07:26 -04:00
|
|
|
}
|
|
|
|
|
2013-01-02 20:44:23 -04:00
|
|
|
bool EmptySemaphore::take_nonblocking() {
|
|
|
|
/* No syncronisation primitives to garuntee this is correct */
|
|
|
|
if (!_taken) {
|
|
|
|
_taken = true;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-17 15:07:26 -04:00
|
|
|
}
|