You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/01/28 04:49:57 UTC

[GitHub] ifplusor commented on a change in pull request #78: [ISSUE #77] optimize process of allocate opaque by atomic without lock.

ifplusor commented on a change in pull request #78: [ISSUE #77] optimize process of allocate opaque by atomic without lock.
URL: https://github.com/apache/rocketmq-client-cpp/pull/78#discussion_r251281931
 
 

 ##########
 File path: src/protocol/RemotingCommand.cpp
 ##########
 @@ -32,11 +33,9 @@ RemotingCommand::RemotingCommand(int code,
       m_flag(0),
       m_remark(""),
       m_pExtHeader(pExtHeader) {
-  boost::lock_guard<boost::mutex> lock(m_clock);
-  m_opaque = (s_seqNumber.load(boost::memory_order_acquire)) %
-             (numeric_limits<int>::max());
-  s_seqNumber.store(m_opaque, boost::memory_order_release);
-  ++s_seqNumber;
+
+  // mask sign bit
+  m_opaque = s_seqNumber.fetch_add(1, boost::memory_order_acq_rel) & numeric_limits<int>::max();
 
 Review comment:
   yeah. yesterday, i change this to 'memory_order_acq_rel' when i try to fix other bug, but that have no relation to memory order. i have revert it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services