Minor refactoring, rename mutex
@@ -9,6 +9,7 @@ import (
"os"
"strings"
"sync"
+ "sync/atomic"
)
type Progress struct {
@@ -18,7 +19,7 @@ type Progress struct {
initialTotal int64
captureData *captureData
termWidth int
- mutex *sync.Mutex
+ stdCaptureMutex *sync.Mutex
stdout *strings.Builder
stderr *strings.Builder
}
@@ -37,7 +38,7 @@ func NewProgress(group *sync.WaitGroup) *Progress {
mpb.PopCompletedMode(),
),
termWidth: tw,
- mutex: &sync.Mutex{},
+ stdCaptureMutex: &sync.Mutex{},
stdout: &strings.Builder{},
stderr: &strings.Builder{},
}
@@ -88,7 +89,7 @@ func (p *Progress) Wait() {
//
func (p *Progress) StartStdCapture() {
- p.mutex.Lock()
+ p.stdCaptureMutex.Lock()
p.captureData = startStdCapture()
}
@@ -96,7 +97,7 @@ func (p *Progress) StopStdCapture() {
stopStdCapture(p.captureData)
p.stdout.Write(p.captureData.DataStdOut.Bytes())
p.stderr.Write(p.captureData.DataStdErr.Bytes())
- p.mutex.Unlock()
+ p.stdCaptureMutex.Unlock()
}
func (p *Progress) ShowStdOut() {
