queue map manager: not using std::atomic anymore

This commit is contained in:
Robin Müller 2020-07-06 14:09:33 +02:00
parent b61e1df8bc
commit 78283ddbee
2 changed files with 5 additions and 2 deletions

View File

@ -17,6 +17,10 @@ QueueMapManager* QueueMapManager::instance() {
ReturnValue_t QueueMapManager::addMessageQueue(
MessageQueueIF* queueToInsert, MessageQueueId_t* id) {
// Not thread-safe, but it is assumed all message queues are created
// at software initialization now. If this is to be made thread-safe in
// the future, it propably would be sufficient to lock the increment
// operation here
uint32_t currentId = queueCounter++;
auto returnPair = queueMap.emplace(currentId, queueToInsert);
if(not returnPair.second) {
@ -28,7 +32,6 @@ ReturnValue_t QueueMapManager::addMessageQueue(
if (id != nullptr) {
*id = currentId;
}
mapLock = MutexFactory::instance()->createMutex();
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -36,7 +36,7 @@ public:
private:
//! External instantiation is forbidden.
QueueMapManager();
std::atomic<uint32_t> queueCounter = 1;
uint32_t queueCounter = 1;
MutexIF* mapLock;
QueueMap queueMap;
static QueueMapManager* mqManagerInstance;