Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2016-11-28 07:53:57 -0500
committerHenrik Rentz-Reichert2016-11-28 07:53:57 -0500
commit84c90477299b193084af9462eb4f32b0615deef5 (patch)
tree9032617ac4fcee3291184878a1fb91324460ca2f
parent31177028a91c9e672f8ab6ee46f1d239e014b06f (diff)
downloadorg.eclipse.etrice-84c90477299b193084af9462eb4f32b0615deef5.tar.gz
org.eclipse.etrice-84c90477299b193084af9462eb4f32b0615deef5.tar.xz
org.eclipse.etrice-84c90477299b193084af9462eb4f32b0615deef5.zip
Bug 348173 - message services should be started according to thread prio
* generated code for creating and adding message services is sorted in descending priority * runtimes changed to consider order Change-Id: I78fb0686efc5d88a791eba1bf99c0e28c4cc68eb
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp35
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h8
2 files changed, 21 insertions, 22 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
index 7ca18e7ee..7ac21eb4e 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
@@ -11,13 +11,13 @@
*******************************************************************************/
#include <algorithm>
+
#include "MessageServiceController.h"
namespace etRuntime {
MessageServiceController::MessageServiceController() :
m_messageServices(),
- m_messageServicesOrdered(),
m_freeIDs(),
m_running(false),
m_nextFreeID(0),
@@ -51,40 +51,40 @@ void MessageServiceController::addMsgSvc(IMessageService& msgSvc) {
if (m_nextFreeID <= msgSvc.getAddress().m_threadID)
m_nextFreeID = msgSvc.getAddress().m_threadID + 1;
- m_messageServices[msgSvc.getAddress().m_threadID] = &msgSvc;
- m_messageServicesOrdered.push_back(&msgSvc);
+ m_messageServices.push_back(&msgSvc);
etMutex_leave(&m_mutex);
}
void MessageServiceController::removeMsgSvc(IMessageService& msgSvc) {
etMutex_enter(&m_mutex);
- m_messageServices.erase(msgSvc.getAddress().m_threadID);
- std::vector<IMessageService*>::iterator it = std::find(m_messageServicesOrdered.begin(), m_messageServicesOrdered.end(), &msgSvc);
- m_messageServicesOrdered.erase(it);
+
+ MsgSvcList::iterator it = std::find(m_messageServices.begin(), m_messageServices.end(), &msgSvc);
+ if (it!=m_messageServices.end()) {
+ m_messageServices.erase(it);
+ }
etMutex_leave(&m_mutex);
}
IMessageService* MessageServiceController::getMsgSvc(int id) {
IMessageService* msgSvc = 0;
etMutex_enter(&m_mutex);
- std::map<int, IMessageService*>::iterator it = m_messageServices.find(id);
- if(it != m_messageServices.end())
- msgSvc = it->second;
+ for (MsgSvcList::iterator it = m_messageServices.begin(); it!=m_messageServices.end(); ++it) {
+ if ((*it)->getAddress().m_threadID==id) {
+ msgSvc = *it;
+ break;
+ }
+ }
etMutex_leave(&m_mutex);
return msgSvc;
}
void MessageServiceController::start() {
- etMutex_enter(&m_mutex);
-
// start all message services
- for (std::vector<IMessageService*>::iterator it = m_messageServicesOrdered.begin(); it != m_messageServicesOrdered.end(); ++it) {
+ for (MsgSvcList::iterator it = m_messageServices.begin(); it != m_messageServices.end(); ++it) {
(*it)->start();
}
m_running = true;
-
- etMutex_leave(&m_mutex);
}
void MessageServiceController::stop() {
@@ -119,10 +119,9 @@ void MessageServiceController::dumpThreads(std::string msg) {
void MessageServiceController::terminate() {
// terminate all message services
etMutex_enter(&m_mutex);
- m_terminateServices = m_messageServicesOrdered;
+ m_terminateServices = m_messageServices;
- // stop in reverse order
- std::vector<IMessageService*>::reverse_iterator it = m_terminateServices.rbegin();
+ MsgSvcList::reverse_iterator it = m_terminateServices.rbegin();
for (; it != m_terminateServices.rend(); ++it) {
(*it)->terminate();
}
@@ -155,7 +154,7 @@ void MessageServiceController::resetAll() {
void MessageServiceController::setMsgSvcTerminated(const IMessageService& msgSvc){
etMutex_enter(&m_mutex);
- std::vector<IMessageService*>::iterator it = std::find(m_terminateServices.begin(), m_terminateServices.end(), &msgSvc);
+ MsgSvcList::iterator it = std::find(m_terminateServices.begin(), m_terminateServices.end(), &msgSvc);
if (it!=m_terminateServices.end()) {
m_terminateServices.erase(it);
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
index 81724e82d..c9bc85aed 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
@@ -16,7 +16,6 @@
#include "common/messaging/IMessageService.h"
#include "osal/etMutex.h"
#include "osal/etSema.h"
-#include <map>
#include <vector>
#include <queue>
#include <string>
@@ -51,15 +50,16 @@ protected:
private:
void terminate();
- std::map<int, IMessageService*> m_messageServices;
- std::vector<IMessageService*> m_messageServicesOrdered;
+ typedef std::vector<IMessageService*> MsgSvcList;
+
+ MsgSvcList m_messageServices;
std::queue<int> m_freeIDs;
etBool m_running;
int m_nextFreeID;
etMutex m_mutex;
etSema m_terminateSema;
- std::vector<IMessageService*> m_terminateServices;
+ MsgSvcList m_terminateServices;
MessageServiceController(MessageServiceController const&);
MessageServiceController& operator=(MessageServiceController const&);

Back to the top