Explorar o código

Collapse two sync.atomic calls

It doesn't matter since we're inside a mutex anyways, but this is cleaner.
Evan Huus %!s(int64=11) %!d(string=hai) anos
pai
achega
3695413ed2
Modificáronse 1 ficheiros con 1 adicións e 2 borrados
  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
 }