Skip to content

Commit

Permalink
Start writing a little later
Browse files Browse the repository at this point in the history
  • Loading branch information
timdp committed Apr 25, 2018
1 parent 3cecfd9 commit 46b2dc4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/app/lwc/process.go
Expand Up @@ -57,19 +57,12 @@ func ProcessFile(file *os.File, name string, processors []Processor, totals *[]u
// Create counters
counts := make([]uint64, numCounts)

// Write zeroes straightaway in case file is empty
PrintCounts(&counts, name, false, false)

// For each counter, set up a pipe
pipes := make([]lwcio.Pipe, numCounts)
for i := 0; i < numCounts; i++ {
pipes[i] = lwcio.NewPipe()
}

// Update stdout at fixed intervals
done := make(chan bool)
go PollCounts(name, &counts, interval, done)

// Set up WaitGroup for our goroutines
var wg sync.WaitGroup
wg.Add(numCounts)
Expand All @@ -86,6 +79,13 @@ func ProcessFile(file *os.File, name string, processors []Processor, totals *[]u
}(pipes[index].R, processor, &counts[index], totalPtr)
}

// Write zeroes straightaway in case file is empty
PrintCounts(&counts, name, false, false)

// Update stdout at fixed intervals
done := make(chan bool)
go PollCounts(name, &counts, interval, done)

// Write to pipes
lwcio.MultiPipe(file, lwcio.GetPipeWriters(pipes))

Expand Down

0 comments on commit 46b2dc4

Please sign in to comment.