Skip to content

Commit

Permalink
Remove unnecessary volatile keywork
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Mar 25, 2024
1 parent f8fd71f commit b22acc1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/tmx/TmxCore/src/MessageRouterBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ void MessageRouterBasic::broadcastMessage(MessageReceiver *sender, IvpMessage *m

pthread_mutex_lock(&this->mActiveBroadcastsLock);
// Volatile type should not be used in compound operations cpp:S6191
auto val = this->mActiveBroadcasts;
this->mActiveBroadcasts = val + 1;
this->mActiveBroadcasts++;
pthread_mutex_unlock(&this->mActiveBroadcastsLock);

int broadcastCount = 0;
Expand Down Expand Up @@ -107,10 +106,10 @@ void MessageRouterBasic::broadcastMessage(MessageReceiver *sender, IvpMessage *m
}
}
}

// Volatile type should not be used in compound operations cpp:S6191
pthread_mutex_lock(&this->mActiveBroadcastsLock);
auto val = this->mActiveBroadcasts;
this->mActiveBroadcasts = val - 1;
this->mActiveBroadcasts--;
pthread_mutex_unlock(&this->mActiveBroadcastsLock);

//LOG_DEBUG("MessageRouterBasic::broadcastMessage for " << msg->subtype << " from "<< sender->pluginName << " Time (ms) "<<timer_ms);
Expand Down
2 changes: 1 addition & 1 deletion src/tmx/TmxCore/src/MessageRouterBasic.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MessageRouterBasic : public MessageRouter
* Keeps track of how many threads are actively inside the broadcast method in a thread safe manner (using mActiveBroadcastsLock).
* This is to allow concurrent execution of the broadcast, but give the register and unregister methods a way to tell when broadcasts are inactive.
*/
volatile int mActiveBroadcasts;
int mActiveBroadcasts;

/*!
* Used to keep the mActiveBroadcast count accurate since multiple thread's may be accessing.
Expand Down

0 comments on commit b22acc1

Please sign in to comment.