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>
This commit is contained in:
parent
f12130a528
commit
7f9b1623fa
1 changed files with 1 additions and 8 deletions
|
|
@ -52,10 +52,6 @@ type call struct {
|
||||||
val interface{}
|
val interface{}
|
||||||
err error
|
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
|
// These fields are read and written with the singleflight
|
||||||
// mutex held before the WaitGroup is done, and are read but
|
// mutex held before the WaitGroup is done, and are read but
|
||||||
// not written after the WaitGroup is done.
|
// not written after the WaitGroup is done.
|
||||||
|
|
@ -151,7 +147,7 @@ func (g *Group) doCall(c *call, key string, fn func() (interface{}, error)) {
|
||||||
c.wg.Done()
|
c.wg.Done()
|
||||||
g.mu.Lock()
|
g.mu.Lock()
|
||||||
defer g.mu.Unlock()
|
defer g.mu.Unlock()
|
||||||
if !c.forgotten {
|
if g.m[key] == c {
|
||||||
delete(g.m, key)
|
delete(g.m, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,9 +200,6 @@ func (g *Group) doCall(c *call, key string, fn func() (interface{}, error)) {
|
||||||
// an earlier call to complete.
|
// an earlier call to complete.
|
||||||
func (g *Group) Forget(key string) {
|
func (g *Group) Forget(key string) {
|
||||||
g.mu.Lock()
|
g.mu.Lock()
|
||||||
if c, ok := g.m[key]; ok {
|
|
||||||
c.forgotten = true
|
|
||||||
}
|
|
||||||
delete(g.m, key)
|
delete(g.m, key)
|
||||||
g.mu.Unlock()
|
g.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue