Codebase list golang-github-vbauerster-mpb / c23cc58
init shutdownNotifier before ranging options Vladimir Bauer 3 years ago
1 changed file(s) with 10 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
7272 // method has been called.
7373 func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
7474 s := &pState{
75 rr: prr,
76 bHeap: priorityQueue{},
77 rows: make([]io.Reader, 0, 64),
78 pool: make([]*Bar, 0, 64),
79 manualRefresh: make(chan interface{}),
80 queueBars: make(map[*Bar]*Bar),
81 popPriority: math.MinInt32,
82 output: os.Stdout,
83 debugOut: io.Discard,
75 rr: prr,
76 bHeap: priorityQueue{},
77 rows: make([]io.Reader, 0, 64),
78 pool: make([]*Bar, 0, 64),
79 manualRefresh: make(chan interface{}),
80 shutdownNotifier: make(chan struct{}),
81 queueBars: make(map[*Bar]*Bar),
82 popPriority: math.MinInt32,
83 output: os.Stdout,
84 debugOut: io.Discard,
8485 }
8586
8687 for _, opt := range options {
8788 if opt != nil {
8889 opt(s)
8990 }
90 }
91
92 if s.shutdownNotifier == nil {
93 s.shutdownNotifier = make(chan struct{})
9491 }
9592
9693 ctx, cancel := context.WithCancel(ctx)