Use (throttle)Go() convenience.
authorTom Clegg <tom@curii.com>
Tue, 7 Dec 2021 16:01:19 +0000 (11:01 -0500)
committerTom Clegg <tom@curii.com>
Tue, 7 Dec 2021 16:01:19 +0000 (11:01 -0500)
No issue #

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

slice.go

index d2073ad9c05f8900bc55dd8780e30bb6ca8cc699..4dbe6ab652c0d023433903f7bd8c4ecee3477e70 100644 (file)
--- 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 := 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 {
                        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)
                        }
                        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
                                }
                                if err := throttle.Err(); err != nil {
                                        return err
                                }
@@ -241,8 +238,7 @@ func Slice(tagsPerFile int, dstdir string, srcdirs []string) error {
                                }
                                return nil
                        })
                                }
                                return nil
                        })
-                       throttle.Report(err)
-               }()
+               })
        }
        throttle.Wait()
        if throttle.Err() != nil {
        }
        throttle.Wait()
        if throttle.Err() != nil {