Adding Code for Linux
This commit is contained in:
@ -5,11 +5,22 @@
|
||||
|
||||
#include <framework/ipc/MessageQueueMessage.h>
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
class MessageQueueIF {
|
||||
public:
|
||||
|
||||
static const MessageQueueId_t NO_QUEUE = MessageQueueSenderIF::NO_QUEUE; //!< Ugly hack.
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF;
|
||||
/**
|
||||
* No new messages on the queue
|
||||
*/
|
||||
static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(1);
|
||||
/**
|
||||
* No space left for more messages
|
||||
*/
|
||||
static const ReturnValue_t FULL = MAKE_RETURN_CODE(2);
|
||||
|
||||
virtual ~MessageQueueIF() {}
|
||||
/**
|
||||
* @brief This operation sends a message to the last communication partner.
|
||||
@ -65,16 +76,32 @@ public:
|
||||
* This variable is set to zero by default.
|
||||
* \param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full (if implemented).
|
||||
*/
|
||||
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo, MessageQueueMessage* message, MessageQueueId_t sentFrom = NO_QUEUE, bool ignoreFault = false ) = 0;
|
||||
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo, MessageQueueMessage* message, MessageQueueId_t sentFrom, bool ignoreFault = false ) = 0;
|
||||
/**
|
||||
* @brief This operation sends a message to the given destination.
|
||||
* @details It directly uses the sendMessage call of the MessageQueueSender parent, but passes its
|
||||
* queue id as "sentFrom" parameter.
|
||||
* @param sendTo This parameter specifies the message queue id of the destination message queue.
|
||||
* @param message A pointer to a previously created message, which is sent.
|
||||
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full.
|
||||
*/
|
||||
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo, MessageQueueMessage* message, bool ignoreFault = false ) = 0;
|
||||
|
||||
/**
|
||||
* \brief The sendToDefault method sends a queue message to the default destination.
|
||||
* \brief The sendToDefaultFrom method sends a queue message to the default destination.
|
||||
* \details In all other aspects, it works identical to the sendMessage method.
|
||||
* \param message This is a pointer to a previously created message, which is sent.
|
||||
* \param sentFrom The sentFrom information can be set to inject the sender's queue id into the message.
|
||||
* This variable is set to zero by default.
|
||||
*/
|
||||
virtual ReturnValue_t sendToDefault( MessageQueueMessage* message, MessageQueueId_t sentFrom = NO_QUEUE, bool ignoreFault = false ) = 0;
|
||||
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message, MessageQueueId_t sentFrom, bool ignoreFault = false ) = 0;
|
||||
/**
|
||||
* @brief This operation sends a message to the default destination.
|
||||
* @details As in the sendMessage method, this function uses the sendToDefault call of the
|
||||
* Implementation class and adds its queue id as "sentFrom" information.
|
||||
* @param message A pointer to a previously created message, which is sent.
|
||||
*/
|
||||
virtual ReturnValue_t sendToDefault( MessageQueueMessage* message ) = 0;
|
||||
/**
|
||||
* \brief This method is a simple setter for the default destination.
|
||||
*/
|
||||
|
24
ipc/MutexHelper.h
Normal file
24
ipc/MutexHelper.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef FRAMEWORK_IPC_MUTEXHELPER_H_
|
||||
#define FRAMEWORK_IPC_MUTEXHELPER_H_
|
||||
|
||||
#include <framework/ipc/MutexFactory.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
class MutexHelper {
|
||||
public:
|
||||
MutexHelper(MutexIF* mutex, uint32_t timeoutMs) :
|
||||
internalMutex(mutex) {
|
||||
ReturnValue_t status = mutex->lockMutex(timeoutMs);
|
||||
if(status != HasReturnvaluesIF::RETURN_OK){
|
||||
error << "MutexHelper: Lock of Mutex failed " << status << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
~MutexHelper() {
|
||||
internalMutex->unlockMutex();
|
||||
}
|
||||
private:
|
||||
MutexIF* internalMutex;
|
||||
};
|
||||
#endif /* FRAMEWORK_IPC_MUTEXHELPER_H_ */
|
@ -6,6 +6,57 @@
|
||||
class MutexIF {
|
||||
public:
|
||||
static const uint32_t NO_TIMEOUT; //!< Needs to be defined in implementation.
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MUTEX_IF;
|
||||
/**
|
||||
* The system lacked the necessary resources (other than memory) to initialize another mutex.
|
||||
*/
|
||||
static const ReturnValue_t NOT_ENOUGH_RESOURCES = MAKE_RETURN_CODE(1);
|
||||
/**
|
||||
* Insufficient memory to create or init Mutex
|
||||
*/
|
||||
static const ReturnValue_t INSUFFICIENT_MEMORY = MAKE_RETURN_CODE(2);
|
||||
/**
|
||||
* Caller does not have enough or right privilege
|
||||
*/
|
||||
static const ReturnValue_t NO_PRIVILEGE = MAKE_RETURN_CODE(3);
|
||||
/**
|
||||
* Wrong Attribute Setting
|
||||
*/
|
||||
static const ReturnValue_t WRONG_ATTRIBUTE_SETTING = MAKE_RETURN_CODE(4);
|
||||
/**
|
||||
* The mutex is already locked
|
||||
*/
|
||||
static const ReturnValue_t MUTEX_ALREADY_LOCKED = MAKE_RETURN_CODE(5);
|
||||
/**
|
||||
* Mutex object not found
|
||||
*/
|
||||
static const ReturnValue_t MUTEX_NOT_FOUND = MAKE_RETURN_CODE(6);
|
||||
/**
|
||||
* Mutex could not be locked because max amount of recursive locks
|
||||
*/
|
||||
static const ReturnValue_t MUTEX_MAX_LOCKS = MAKE_RETURN_CODE(7);
|
||||
/**
|
||||
* The current thread already owns this mutex
|
||||
*/
|
||||
static const ReturnValue_t CURR_THREAD_ALREADY_OWNS_MUTEX = MAKE_RETURN_CODE(8);
|
||||
/**
|
||||
* Current thread does not own this mutex
|
||||
*/
|
||||
static const ReturnValue_t CURR_THREAD_DOES_NOT_OWN_MUTEX = MAKE_RETURN_CODE(9);
|
||||
/**
|
||||
* The Mutex could not be blocked before timeout
|
||||
*/
|
||||
static const ReturnValue_t MUTEX_TIMEOUT = MAKE_RETURN_CODE(10);
|
||||
/**
|
||||
* Invalid Mutex ID
|
||||
*/
|
||||
static const ReturnValue_t MUTEX_INVALID_ID = MAKE_RETURN_CODE(11);
|
||||
/**
|
||||
* Mutex destroyed while waiting
|
||||
*/
|
||||
static const ReturnValue_t MUTEX_DESTROYED_WHILE_WAITING = MAKE_RETURN_CODE(12);
|
||||
|
||||
virtual ~MutexIF() {}
|
||||
virtual ReturnValue_t lockMutex(uint32_t timeoutMs) = 0;
|
||||
virtual ReturnValue_t unlockMutex() = 0;
|
||||
|
Reference in New Issue
Block a user