add cancel func to Progress
Vladimir Bauer
3 years ago
| 31 | 31 | done chan struct{} |
| 32 | 32 | refreshCh chan time.Time |
| 33 | 33 | once sync.Once |
| 34 | cancel func() | |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | 37 | // pState holds bars in its priorityQueue, it gets passed to (*Progress).serve monitor goroutine. |
| 70 | 71 | // context. It's not possible to reuse instance after (*Progress).Wait |
| 71 | 72 | // method has been called. |
| 72 | 73 | func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress { |
| 74 | ctx, cancel := context.WithCancel(ctx) | |
| 73 | 75 | s := &pState{ |
| 74 | 76 | bHeap: priorityQueue{}, |
| 75 | 77 | rows: make([]io.Reader, 0, 64), |
| 94 | 96 | operateState: make(chan func(*pState)), |
| 95 | 97 | interceptIo: make(chan func(io.Writer)), |
| 96 | 98 | done: make(chan struct{}), |
| 99 | cancel: cancel, | |
| 97 | 100 | } |
| 98 | 101 | |
| 99 | 102 | p.cwg.Add(1) |