Add concurrency limiting semaphore

main
Mari 4 years ago
parent 0dd446c293
commit a719cd25a1
  1. 13
      drive-demuxer.go

@ -16,6 +16,7 @@ type TopLevel struct {
LeftOutput string
CombinedOutput string
RightOutput string
OpenHandles chan int
}
type Step struct {
@ -181,7 +182,7 @@ func (s *Step) ListChildren() []string {
results[file.Name()] = true
}
out := make([]string, 0, len(results))
for file, _ := range results {
for file := range results {
out = append(out, file)
}
return out
@ -298,7 +299,11 @@ func (s *Step) Walk() {
}
wg.Add(1)
go func() {
defer func() { wg.Done() }()
defer func() {
<-s.OpenHandles
wg.Done()
}()
s.OpenHandles <- 1
substep.Walk()
s.RemoveInputDirs(child)
}()
@ -314,7 +319,9 @@ func (s *Step) Walk() {
}
func main() {
settings := TopLevel{}
settings := TopLevel{
OpenHandles: make(chan int, 300),
}
flag.StringVar(&settings.LeftInput,
"left-input", "./input/left", "The name of the left side of the input.")
flag.StringVar(&settings.RightInput,

Loading…
Cancel
Save