(store *DiskCache, peers *PeerManager, cacheHostSuffixes []string)
| 110 | } |
| 111 | |
| 112 | type call struct { |
| 113 | wg sync.WaitGroup |
| 114 | start time.Time |
| 115 | res fetchResult |
| 116 | err error |
| 117 | } |
| 118 | |
| 119 | func (sf *singleFlight) Do(key string, fn func() (fetchResult, error)) (fetchResult, error) { |
| 120 | sf.mu.Lock() |
| 121 | if sf.m == nil { |
| 122 | sf.m = make(map[string]*call) |
| 123 | } |
| 124 | if c, ok := sf.m[key]; ok { |
| 125 | sf.mu.Unlock() |
| 126 | c.wg.Wait() |
no outgoing calls