Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2017-01-04 15:07:12 -0500
committerHenrik Rentz-Reichert2017-01-09 11:41:16 -0500
commit9b02d5a62ea41136b46b744f7b2c1cf50f30a888 (patch)
treed7473847da1a9e3a470195f384f62322b48057db /runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
parentb8fd69cd558c0673971bcdaea495131bc4d7cd82 (diff)
downloadorg.eclipse.etrice-9b02d5a62ea41136b46b744f7b2c1cf50f30a888.tar.gz
org.eclipse.etrice-9b02d5a62ea41136b46b744f7b2c1cf50f30a888.tar.xz
org.eclipse.etrice-9b02d5a62ea41136b46b744f7b2c1cf50f30a888.zip
Bug 509875 - [runtime.cpp] replace STL containers with own containers that are more light weight
* replaced streaming code with (s)printf constructs * added String, Vector, Set, Pair and Map with tests * using new String class in * Address * Message * MSCFilter * MSCLogger * RTObject * and affected classes * using new Vector class in * RTObject * MSCLogger * MessageServiceController * ReplicatedActorClassBase * ReplicatedInterfaceItemBase * and affected classes * using new Set class in * MessageDispatcher * using new Map class in * SubSystemClassBase * DebuggingService * adjusted cpp generator Change-Id: I9c91289057185e6e36b9453ecf03f6f6d3834ec6
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp')
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp26
1 files changed, 18 insertions, 8 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 7ac21eb4e..a5697e2ae 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
@@ -10,12 +10,22 @@
*
*******************************************************************************/
-#include <algorithm>
-
#include "MessageServiceController.h"
+#include "common/containers/String.h"
namespace etRuntime {
+typedef Vector<IMessageService*>::iterator iterator;
+static iterator find(iterator begin, iterator end, const IMessageService* value) {
+ iterator current = begin;
+ for (; current!=end; ++current) {
+ if (*current==value) {
+ return current;
+ }
+ }
+ return current;
+}
+
MessageServiceController::MessageServiceController() :
m_messageServices(),
m_freeIDs(),
@@ -33,7 +43,7 @@ int MessageServiceController::getNewID() {
newID = m_nextFreeID++;
else {
newID = m_freeIDs.back();
- m_freeIDs.pop();
+ m_freeIDs.pop_back();
}
etMutex_leave(&m_mutex);
@@ -42,7 +52,7 @@ int MessageServiceController::getNewID() {
void MessageServiceController::freeID(int id) {
etMutex_enter(&m_mutex);
- m_freeIDs.push(id);
+ m_freeIDs.push_back(id);
etMutex_leave(&m_mutex);
}
@@ -58,7 +68,7 @@ void MessageServiceController::addMsgSvc(IMessageService& msgSvc) {
void MessageServiceController::removeMsgSvc(IMessageService& msgSvc) {
etMutex_enter(&m_mutex);
- MsgSvcList::iterator it = std::find(m_messageServices.begin(), m_messageServices.end(), &msgSvc);
+ MsgSvcList::iterator it = find(m_messageServices.begin(), m_messageServices.end(), &msgSvc);
if (it!=m_messageServices.end()) {
m_messageServices.erase(it);
}
@@ -98,7 +108,7 @@ void MessageServiceController::stop() {
m_running = false;
}
-void MessageServiceController::dumpThreads(std::string msg) {
+void MessageServiceController::dumpThreads(String msg) {
// std::cout << "<<< begin dump threads <<<" << std::endl;
// std::cout << "=== " << msg << std::endl;
//TODO dump stack traces
@@ -146,7 +156,7 @@ void MessageServiceController::resetAll() {
etMutex_enter(&m_mutex);
m_messageServices.clear();
while (!m_freeIDs.empty()) {
- m_freeIDs.pop();
+ m_freeIDs.pop_back();
}
m_nextFreeID = 0;
etMutex_leave(&m_mutex);
@@ -154,7 +164,7 @@ void MessageServiceController::resetAll() {
void MessageServiceController::setMsgSvcTerminated(const IMessageService& msgSvc){
etMutex_enter(&m_mutex);
- MsgSvcList::iterator it = std::find(m_terminateServices.begin(), m_terminateServices.end(), &msgSvc);
+ MsgSvcList::iterator it = find(m_terminateServices.begin(), m_terminateServices.end(), &msgSvc);
if (it!=m_terminateServices.end()) {
m_terminateServices.erase(it);
}

Back to the top