Skip to content

Commit 5e24338

Browse files
committed
PR feedback
1 parent be10acb commit 5e24338

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

singleflight/singleflight.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ type Result struct {
4646
Shared bool
4747
}
4848

49+
// RefCounter is retuned by Group.DoRefCount and contains information on how many callers got same return result
50+
/// Each caller to execute RefCounter.Decrement method, once done using resource returned by 'Group.DoRefCount'.
51+
// 'RefCounter.Decrement' for last caller will return true, at which point resource cleanup can be carried out
4952
type RefCounter struct {
5053
ptr *int64
5154
zero int64
@@ -61,8 +64,10 @@ func (v RefCounter) Decrement() bool {
6164
// sure that only one execution is in-flight for a given key at a
6265
// time. If a duplicate comes in, the duplicate caller waits for the
6366
// original to complete and receives the same results.
64-
// DoRefCount should NOT be mixed for same key with Do/DoChan to avoid race condition in calulating "shared" retiun value
67+
// DoRefCount should NOT be mixed for same key with Do/DoChan to avoid race condition in calculating "shared" return value
6568
// The return value refCount maintains "reference counter" for multiple callers.
69+
// Each caller to execute 'RefCounter.Decrement' method, once done using returned resource.
70+
// 'RefCounter.Decrement' for last caller will return true, at which point resource cleanup can be carried out
6671
func (g *Group) DoRefCount(key string, fn func() (interface{}, error)) (v interface{}, err error, refCount RefCounter) {
6772
c := g.doNoChan(key, fn)
6873

0 commit comments

Comments
 (0)