Browse Source

Collapse two sync.atomic calls

It doesn't matter since we're inside a mutex anyways, but this is cleaner.
Evan Huus 10 years ago
parent
commit
3695413ed2
1 changed files with 1 additions and 2 deletions
  1. 1 2
      mocks/consumer.go

+ 1 - 2
mocks/consumer.go

@@ -264,10 +264,9 @@ func (pc *PartitionConsumer) YieldMessage(msg *sarama.ConsumerMessage) {
 	pc.l.Lock()
 	defer pc.l.Unlock()
 
-	atomic.AddInt64(&pc.highWaterMarkOffset, 1)
 	msg.Topic = pc.topic
 	msg.Partition = pc.partition
-	msg.Offset = atomic.LoadInt64(&pc.highWaterMarkOffset)
+	msg.Offset = atomic.AddInt64(&pc.highWaterMarkOffset, 1)
 
 	pc.messages <- msg
 }