BewareMyPower commented on code in PR #16940:
URL: https://github.com/apache/pulsar/pull/16940#discussion_r937497183


##########
pulsar-client-cpp/lib/ProducerImpl.cc:
##########
@@ -726,10 +716,10 @@ Future<Result, ProducerImplBaseWeakPtr> 
ProducerImpl::getProducerCreatedFuture()
 uint64_t ProducerImpl::getProducerId() const { return producerId_; }
 
 void ProducerImpl::handleSendTimeout(const boost::system::error_code& err) {
-    Lock lock(mutex_);
     if (state_ != Pending && state_ != Ready) {

Review Comment:
   ```suggestion
       const auto state = state_.load();
       if (state != Pending && state != Ready) {
   ```
   
   Not sure if the compiler will optimize it (read the same value for the two 
`state_ != xxx` comparisons). But it's better to get the current state only 
once explicitly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to