mirror of
https://github.com/kopia/kopia.git
synced 2026-10-20 05:14:00 -04:00
restore: support for parallelization (#668)
This commit is contained in:
1 parent
4fd0bcf7dc
commit
ec9c4d6095
6 files changed
+105
-28
No files matched your search
@@ -138,6 +138,24 @@ func (v *Queue) maybeReportProgress() {
|
||||
cb(v.enqueuedWork, v.activeWorkerCount, v.completedWork)
|
||||
}
|
||||
|
||||
// OnNthCompletion invokes the provided callback once the returned callback function has been invoked exactly n times.
|
||||
func OnNthCompletion(n int, callback CallbackFunc) CallbackFunc {
|
||||
var mu sync.Mutex
|
||||
|
||||
return func() error {
|
||||
mu.Lock()
|
||||
n--
|
||||
call := n == 0
|
||||
mu.Unlock()
|
||||
|
||||
if call {
|
||||
return callback()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewQueue returns new parallel work queue.
|
||||
func NewQueue() *Queue {
|
||||
return &Queue{
|
||||
|
||||
Reference in new issue
Block a user