aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/progress_windows.go
blob: cab03d36c658b1eed0b68df8a29002521147daec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// +build windows

package mpb

import (
	"time"
)

func (p *Progress) serve(s *pState) {

	var ticker *time.Ticker
	var refreshCh <-chan time.Time

	if s.manualRefreshCh == nil {
		ticker = time.NewTicker(s.rr)
		refreshCh = ticker.C
	} else {
		refreshCh = s.manualRefreshCh
	}

	for {
		select {
		case op := <-p.operateState:
			op(s)
		case <-refreshCh:
			if s.zeroWait {
				if s.manualRefreshCh == nil {
					ticker.Stop()
				}
				if s.shutdownNotifier != nil {
					close(s.shutdownNotifier)
				}
				close(p.done)
				return
			}
			tw, err := s.cw.GetWidth()
			if err != nil {
				tw = s.width
			}
			s.render(tw)
		}
	}
}