Skip to content

Commit 7f9b162

Browse files
cuonglmgopherbot
authored andcommitted
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 <bcmills@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent f12130a commit 7f9b162

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

singleflight/singleflight.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ type call struct {
5252
val interface{}
5353
err error
5454

55-
// forgotten indicates whether Forget was called with this call's key
56-
// while the call was still in flight.
57-
forgotten bool
58-
5955
// These fields are read and written with the singleflight
6056
// mutex held before the WaitGroup is done, and are read but
6157
// not written after the WaitGroup is done.
@@ -151,7 +147,7 @@ func (g *Group) doCall(c *call, key string, fn func() (interface{}, error)) {
151147
c.wg.Done()
152148
g.mu.Lock()
153149
defer g.mu.Unlock()
154-
if !c.forgotten {
150+
if g.m[key] == c {
155151
delete(g.m, key)
156152
}
157153

@@ -204,9 +200,6 @@ func (g *Group) doCall(c *call, key string, fn func() (interface{}, error)) {
204200
// an earlier call to complete.
205201
func (g *Group) Forget(key string) {
206202
g.mu.Lock()
207-
if c, ok := g.m[key]; ok {
208-
c.forgotten = true
209-
}
210203
delete(g.m, key)
211204
g.mu.Unlock()
212205
}

0 commit comments

Comments
 (0)