@ -65,10 +65,6 @@ type call[V any] struct {
val V
val V
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.
@ -161,10 +157,10 @@ func (g *Group[K, V]) doCall(c *call[V], key K, fn func() (V, error)) {
c . err = errGoexit
c . err = errGoexit
}
}
c . wg . Done ( )
g . mu . Lock ( )
g . mu . Lock ( )
defer g . mu . Unlock ( )
defer g . mu . Unlock ( )
if ! c . forgotten {
c . wg . Done ( )
if g . m [ key ] == c {
delete ( g . m , key )
delete ( g . m , key )
}
}
@ -217,9 +213,6 @@ func (g *Group[K, V]) doCall(c *call[V], key K, fn func() (V, error)) {
// an earlier call to complete.
// an earlier call to complete.
func ( g * Group [ K , V ] ) Forget ( key K ) {
func ( g * Group [ K , V ] ) Forget ( key K ) {
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 ( )
}
}