From 6be507a24fb7865ba233d7a9dbe861675f54183a Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Tue, 7 Dec 2021 11:01:19 -0500 Subject: [PATCH] Use (throttle)Go() convenience. No issue # Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- slice.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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 { -- 2.30.2