From 7b574523c8c3cd6d7aea1e24d20dbc11ef530ba4 Mon Sep 17 00:00:00 2001 From: detailyang Date: Wed, 6 Mar 2019 16:12:27 +0800 Subject: [PATCH] bugfix: uint64 is never less than 0 --- queue/ring.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queue/ring.go b/queue/ring.go index dfd0b53..d8ac024 100644 --- a/queue/ring.go +++ b/queue/ring.go @@ -95,7 +95,7 @@ L: n = rb.nodes[pos&rb.mask] seq := atomic.LoadUint64(&n.position) - switch dif := seq - pos; { + switch dif := int64(seq) - int64(pos); { case dif == 0: if atomic.CompareAndSwapUint64(&rb.queue, pos, pos+1) { break L @@ -148,7 +148,7 @@ L: n = rb.nodes[pos&rb.mask] seq := atomic.LoadUint64(&n.position) - switch dif := seq - (pos + 1); { + switch dif := int64(seq) - int64(pos + 1); { case dif == 0: if atomic.CompareAndSwapUint64(&rb.dequeue, pos, pos+1) { break L