Codebase list golang-github-vbauerster-mpb / 474f273
Some refactoring Vladimir Bauer 8 years ago
2 changed file(s) with 10 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
4040 }
4141
4242 type (
43 refill struct {
44 char rune
45 till int64
46 }
4743 state struct {
4844 id int
4945 width int
6763 bufP, bufB, bufA *bytes.Buffer
6864 panic string
6965 }
66 refill struct {
67 char rune
68 till int64
69 }
7070 writeBuf struct {
7171 buf []byte
7272 completeAfterFlush bool
113113 // RemoveBar removes bar at any time.
114114 func (p *Progress) RemoveBar(b *Bar) bool {
115115 result := make(chan bool, 1)
116 op := func(c *pConf) {
116 select {
117 case p.ops <- func(c *pConf) {
117118 var ok bool
118119 for i, bar := range c.bars {
119120 if bar == b {
124125 }
125126 }
126127 result <- ok
127 }
128 select {
129 case p.ops <- op:
128 }:
130129 return <-result
131130 case <-p.quit:
132131 return false
136135 // BarCount returns bars count
137136 func (p *Progress) BarCount() int {
138137 result := make(chan int, 1)
139 op := func(c *pConf) {
138 select {
139 case p.ops <- func(c *pConf) {
140140 result <- len(c.bars)
141 }
142 select {
143 case p.ops <- op:
141 }:
144142 return <-result
145143 case <-p.quit:
146144 return 0