From: Tom Clegg Date: Tue, 7 Dec 2021 16:01:19 +0000 (-0500) Subject: Use (throttle)Go() convenience. X-Git-Url: https://git.arvados.org/lightning.git/commitdiff_plain/6be507a24fb7865ba233d7a9dbe861675f54183a Use (throttle)Go() convenience. No issue # Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- diff --git a/slice.go b/slice.go index d2073ad9c0..4dbe6ab652 100644 --- a/slice.go +++ b/slice.go @@ -136,19 +136,16 @@ func Slice(tagsPerFile int, dstdir string, srcdirs []string) error { throttle := throttle{Max: runtime.GOMAXPROCS(0)} for _, infile := range infiles { infile := infile - throttle.Acquire() - go func() { - defer throttle.Release() + throttle.Go(func() error { f, err := open(infile) if err != nil { - throttle.Report(err) - return + return err } defer f.Close() dir, _ := filepath.Split(infile) namespace := dirNamespace[dir] log.Printf("reading %s (namespace %d)", infile, namespace) - err = DecodeLibrary(f, strings.HasSuffix(infile, ".gz"), func(ent *LibraryEntry) error { + return DecodeLibrary(f, strings.HasSuffix(infile, ".gz"), func(ent *LibraryEntry) error { if err := throttle.Err(); err != nil { return err } @@ -241,8 +238,7 @@ func Slice(tagsPerFile int, dstdir string, srcdirs []string) error { } return nil }) - throttle.Report(err) - }() + }) } throttle.Wait() if throttle.Err() != nil {