[sync] singleflight: remove forgotten field

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Sep 23, 2022, 4:29:45 PM9/23/22
to Cuong Manh Le, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Cherry Mui, Bryan Mills, Brad Fitzpatrick, Ian Lance Taylor, golang-co...@googlegroups.com

Gopher Robot submitted this change.

View Change


Approvals: Cuong Manh Le: Run TryBots; Automatically submit change Bryan Mills: Looks good to me, approved Gopher Robot: TryBots succeeded Cherry Mui: Looks good to me, but someone else must approve
singleflight: remove forgotten field

Port from CL 433315.

Change-Id: Iaf6ab4676dd10a73443c3c9981ffc77233b4631c
Reviewed-on: https://go-review.googlesource.com/c/sync/+/433555
Reviewed-by: Bryan Mills <bcm...@google.com>
Run-TryBot: Cuong Manh Le <cuong.m...@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.m...@gmail.com>
Reviewed-by: Cherry Mui <cher...@google.com>
TryBot-Result: Gopher Robot <go...@golang.org>
---
M singleflight/singleflight.go
1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/singleflight/singleflight.go b/singleflight/singleflight.go
index 690eb85..7c7fc50 100644
--- a/singleflight/singleflight.go
+++ b/singleflight/singleflight.go
@@ -52,10 +52,6 @@
val interface{}
err error

- // forgotten indicates whether Forget was called with this call's key
- // while the call was still in flight.
- forgotten bool
-
// These fields are read and written with the singleflight
// mutex held before the WaitGroup is done, and are read but
// not written after the WaitGroup is done.
@@ -151,7 +147,7 @@
c.wg.Done()
g.mu.Lock()
defer g.mu.Unlock()
- if !c.forgotten {
+ if g.m[key] == c {
delete(g.m, key)
}

@@ -204,9 +200,6 @@
// an earlier call to complete.
func (g *Group) Forget(key string) {
g.mu.Lock()
- if c, ok := g.m[key]; ok {
- c.forgotten = true
- }
delete(g.m, key)
g.mu.Unlock()
}

To view, visit change 433555. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: sync
Gerrit-Branch: master
Gerrit-Change-Id: Iaf6ab4676dd10a73443c3c9981ffc77233b4631c
Gerrit-Change-Number: 433555
Gerrit-PatchSet: 2
Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@tailscale.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages