merlimat commented on a change in pull request #451:
URL: https://github.com/apache/pulsar-client-go/pull/451#discussion_r564217129



##########
File path: pulsar/producer_partition.go
##########
@@ -703,8 +707,22 @@ func (p *partitionProducer) Flush() error {
        return cp.err
 }
 
+func (p *partitionProducer) getProduerState() producerState {
+       return producerState(p.state.Load())
+}
+
+func (p *partitionProducer) setProducerState(state producerState) {
+       p.state.Swap(int32(state))
+}
+
+// set a new consumerState and return the last state
+// returns bool if the new state has been set or not
+func (p *partitionProducer) casProducerState(oldState, newState producerState) 
bool {
+       return p.state.CAS(int32(oldState), int32(newState))
+}
+
 func (p *partitionProducer) Close() {
-       if atomic.LoadInt32(&p.state) != producerReady {
+       if p.getProduerState() != producerReady {

Review comment:
       ```suggestion
        if p.getProducerState() != producerReady {
   ```




----------------------------------------------------------------
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.

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


Reply via email to