Make parallel hasher configurable, remove finisher setting (fixes #1199)

This commit is contained in:
Audrius Butkevicius
2014-12-24 23:12:12 +00:00
parent 5d173168cc
commit 5827a686b8
5 changed files with 20 additions and 19 deletions

View File

@@ -49,6 +49,8 @@ type Walker struct {
// detected. Scanned files will get zero permission bits and the
// NoPermissionBits flag set.
IgnorePerms bool
// Number of routines to use for hashing
Hashers int
}
type TempNamer interface {
@@ -75,9 +77,14 @@ func (w *Walker) Walk() (chan protocol.FileInfo, error) {
return nil, err
}
workers := w.Hashers
if workers < 1 {
workers = runtime.NumCPU()
}
files := make(chan protocol.FileInfo)
hashedFiles := make(chan protocol.FileInfo)
newParallelHasher(w.Dir, w.BlockSize, runtime.NumCPU(), hashedFiles, files)
newParallelHasher(w.Dir, w.BlockSize, workers, hashedFiles, files)
go func() {
hashFiles := w.walkAndHashFiles(files)