File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -612,11 +612,17 @@ func New64(max int64) *ProgressBar {
612
612
613
613
// GetMax returns the max of a bar
614
614
func (p * ProgressBar ) GetMax () int {
615
+ p .lock .Lock ()
616
+ defer p .lock .Unlock ()
617
+
615
618
return int (p .config .max )
616
619
}
617
620
618
621
// GetMax64 returns the current max
619
622
func (p * ProgressBar ) GetMax64 () int64 {
623
+ p .lock .Lock ()
624
+ defer p .lock .Unlock ()
625
+
620
626
return p .config .max
621
627
}
622
628
@@ -632,13 +638,17 @@ func (p *ProgressBar) ChangeMax(newMax int) {
632
638
// but takes in a int64
633
639
// to avoid casting
634
640
func (p * ProgressBar ) ChangeMax64 (newMax int64 ) {
641
+ p .lock .Lock ()
642
+
635
643
p .config .max = newMax
636
644
637
645
if p .config .showBytes {
638
646
p .config .maxHumanized , p .config .maxHumanizedSuffix = humanizeBytes (float64 (p .config .max ),
639
647
p .config .useIECUnits )
640
648
}
641
649
650
+ p .lock .Unlock () // so p.Add can lock
651
+
642
652
p .Add (0 ) // re-render
643
653
}
644
654
You can’t perform that action at this time.
0 commit comments