WIP: somethings wrong.. #19
@ -25,15 +25,16 @@ BinarySemaphore& BinarySemaphore::operator =(
|
|||||||
return * this;
|
return * this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t BinarySemaphore::acquire(uint32_t timeoutMs) {
|
ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType,
|
||||||
|
uint32_t timeoutMs) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(timeoutMs == SemaphoreIF::POLLING) {
|
if(timeoutType == TimeoutType::POLLING) {
|
||||||
result = sem_trywait(&handle);
|
result = sem_trywait(&handle);
|
||||||
}
|
}
|
||||||
else if(timeoutMs == SemaphoreIF::BLOCKING) {
|
else if(timeoutType == TimeoutType::BLOCKING) {
|
||||||
result = sem_wait(&handle);
|
result = sem_wait(&handle);
|
||||||
}
|
}
|
||||||
else if(timeoutMs > SemaphoreIF::POLLING){
|
else if(timeoutType == TimeoutType::WAITING){
|
||||||
timespec timeOut;
|
timespec timeOut;
|
||||||
clock_gettime(CLOCK_REALTIME, &timeOut);
|
clock_gettime(CLOCK_REALTIME, &timeOut);
|
||||||
uint64_t nseconds = timeOut.tv_sec * 1000000000 + timeOut.tv_nsec;
|
uint64_t nseconds = timeOut.tv_sec * 1000000000 + timeOut.tv_nsec;
|
||||||
|
@ -49,8 +49,8 @@ public:
|
|||||||
* @return -@c RETURN_OK on success
|
* @return -@c RETURN_OK on success
|
||||||
* -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout
|
* -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout
|
||||||
*/
|
*/
|
||||||
ReturnValue_t acquire(uint32_t timeoutMs =
|
ReturnValue_t acquire(TimeoutType timeoutType = TimeoutType::BLOCKING,
|
||||||
SemaphoreIF::BLOCKING) override;
|
uint32_t timeoutMs = 0) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release the binary semaphore.
|
* Release the binary semaphore.
|
||||||
|
@ -39,8 +39,11 @@ uint32_t FixedTimeslotTask::getPeriodMs() const {
|
|||||||
|
|
||||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||||
uint32_t slotTimeMs, int8_t executionStep) {
|
uint32_t slotTimeMs, int8_t executionStep) {
|
||||||
if (objectManager->get<ExecutableObjectIF>(componentId) != nullptr) {
|
ExecutableObjectIF* executableObject =
|
||||||
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
objectManager->get<ExecutableObjectIF>(componentId);
|
||||||
|
if (executableObject != nullptr) {
|
||||||
|
pst.addSlot(componentId, slotTimeMs, executionStep,
|
||||||
|
executableObject,this);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
#include "../../osal/linux/CountingSemaphore.h"
|
#include "../../osal/linux/CountingSemaphore.h"
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
|
||||||
const uint32_t SemaphoreIF::POLLING = 0;
|
|
||||||
const uint32_t SemaphoreIF::BLOCKING = 0xffffffff;
|
|
||||||
|
|
||||||
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
|
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
|
||||||
|
|
||||||
SemaphoreFactory::SemaphoreFactory() {
|
SemaphoreFactory::SemaphoreFactory() {
|
||||||
|
Loading…
Reference in New Issue
Block a user