From 6cd8d008ebbb9aebfe45bf16fe39e9293e5e3b50 Mon Sep 17 00:00:00 2001 From: huangqian Date: Sun, 14 Nov 2021 21:35:00 +0800 Subject: [PATCH] Modifying LockIteratorPrev to RLockIteratorPrev and its implementation --- container/gring/gring.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/container/gring/gring.go b/container/gring/gring.go index 08fddc982..08c4e51ab 100644 --- a/container/gring/gring.go +++ b/container/gring/gring.go @@ -193,17 +193,17 @@ func (r *Ring) RLockIteratorNext(f func(value interface{}) bool) { } } -// LockIteratorPrev iterates and locks writing backward +// RLockIteratorPrev iterates and locks writing backward // with given callback function `f` within RWMutex.RLock. // If `f` returns true, then it continues iterating; or false to stop. -func (r *Ring) LockIteratorPrev(f func(item *ring.Ring) bool) { +func (r *Ring) RLockIteratorPrev(f func(value interface{}) bool) { r.mu.RLock() defer r.mu.RUnlock() - if !f(r.ring) { + if r.ring.Value != nil && !f(r.ring.Value.(internalRingItem).Value) { return } for p := r.ring.Prev(); p != r.ring; p = p.Prev() { - if !f(p) { + if p.Value == nil || !f(p.Value.(internalRingItem).Value) { break } }