| 46 | 46 |
}
|
| 47 | 47 |
|
| 48 | 48 |
// Decorator interface.
|
|
49 |
// A decorator must implement this interface, in order to be used with mpb library.
|
| 49 | 50 |
type Decorator interface {
|
| 50 | 51 |
Decor(*Statistics) string
|
| 51 | |
SyncWidth() (bool, chan int)
|
|
52 |
Syncable
|
|
53 |
}
|
|
54 |
|
|
55 |
// Syncable interface.
|
|
56 |
// All decorators implement this interface implicitly.
|
|
57 |
// Its Syncable method exposes width sync channel, if sync is enabled.
|
|
58 |
type Syncable interface {
|
|
59 |
Syncable() (bool, chan int)
|
| 52 | 60 |
}
|
| 53 | 61 |
|
| 54 | 62 |
// OnCompleteMessenger interface.
|
|
| 57 | 65 |
OnCompleteMessage(string)
|
| 58 | 66 |
}
|
| 59 | 67 |
|
|
68 |
// AmountReceiver interface.
|
|
69 |
// If decorator needs to receive increment amount,
|
|
70 |
// so this is the right interface to implement.
|
| 60 | 71 |
type AmountReceiver interface {
|
| 61 | 72 |
NextAmount(int, ...time.Duration)
|
| 62 | 73 |
}
|
| 63 | 74 |
|
| 64 | 75 |
// ShutdownListener interface.
|
| 65 | |
// If decorator implements this interface, its Shutdown method
|
| 66 | |
// will be called once on bar shutdown event.
|
|
76 |
// If decorator needs to be notified once upon bar shutdown event,
|
|
77 |
// so this is the right interface to implement.
|
| 67 | 78 |
type ShutdownListener interface {
|
| 68 | 79 |
Shutdown()
|
| 69 | 80 |
}
|
|
| 114 | 125 |
}
|
| 115 | 126 |
}
|
| 116 | 127 |
|
| 117 | |
func (wc *WC) SyncWidth() (bool, chan int) {
|
|
128 |
func (wc *WC) Syncable() (bool, chan int) {
|
| 118 | 129 |
return (wc.C & DSyncWidth) != 0, wc.wsync
|
| 119 | 130 |
}
|
| 120 | 131 |
|
|
| 131 | 142 |
return decorator
|
| 132 | 143 |
}
|
| 133 | 144 |
|
|
145 |
// completeMsg for internal usage.
|
| 134 | 146 |
type completeMsg struct {
|
| 135 | 147 |
msg string
|
| 136 | 148 |
}
|