MCPcopy Index your code
hub / github.com/kopia/kopia / OnNthCompletion

Function OnNthCompletion

internal/parallelwork/parallel_work_queue.go:149–166  ·  view source on GitHub ↗

OnNthCompletion invokes the provided callback once the returned callback function has been invoked exactly n times.

(n int, callback CallbackFunc)

Source from the content-addressed store, hash-verified

147
148// OnNthCompletion invokes the provided callback once the returned callback function has been invoked exactly n times.
149func OnNthCompletion(n int, callback CallbackFunc) CallbackFunc {
150 var mu sync.Mutex
151
152 return func() error {
153 mu.Lock()
154
155 n--
156 call := n == 0
157
158 mu.Unlock()
159
160 if call {
161 return callback()
162 }
163
164 return nil
165 }
166}
167
168// NewQueue returns new parallel work queue.
169func NewQueue() *Queue {

Callers 2

TestOnNthCompletionFunction · 0.92
copyDirectoryContentMethod · 0.92

Calls 3

callbackFuncType · 0.85
LockMethod · 0.65
UnlockMethod · 0.65

Tested by 1

TestOnNthCompletionFunction · 0.74