| 54 | 54 |
// A decorator must implement this interface, in order to be used with
|
| 55 | 55 |
// mpb library.
|
| 56 | 56 |
type Decorator interface {
|
|
57 |
Synchronizer
|
| 57 | 58 |
Decor(*Statistics) string
|
| 58 | |
Syncable
|
| 59 | 59 |
}
|
| 60 | 60 |
|
| 61 | |
// Syncable interface.
|
| 62 | |
// All decorators implement this interface implicitly. Its Syncable
|
|
61 |
// Synchronizer interface.
|
|
62 |
// All decorators implement this interface implicitly. Its Sync
|
| 63 | 63 |
// method exposes width sync channel, if sync is enabled.
|
| 64 | |
type Syncable interface {
|
| 65 | |
Syncable() (bool, chan int)
|
|
64 |
type Synchronizer interface {
|
|
65 |
Sync() (chan int, bool)
|
| 66 | 66 |
}
|
| 67 | 67 |
|
| 68 | 68 |
// OnCompleteMessenger interface.
|
|
| 96 | 96 |
|
| 97 | 97 |
// WC is a struct with two public fields W and C, both of int type.
|
| 98 | 98 |
// W represents width and C represents bit set of width related config.
|
| 99 | |
// A decorator should embed WC, in order to become Syncable.
|
|
99 |
// A decorator should embed WC, to enable width synchronization.
|
| 100 | 100 |
type WC struct {
|
| 101 | 101 |
W int
|
| 102 | 102 |
C int
|
|
| 133 | 133 |
}
|
| 134 | 134 |
}
|
| 135 | 135 |
|
| 136 | |
// Syncable is implementation of Syncable interface.
|
| 137 | |
func (wc *WC) Syncable() (bool, chan int) {
|
| 138 | |
return (wc.C & DSyncWidth) != 0, wc.wsync
|
|
136 |
// Sync is implementation of Synchronizer interface.
|
|
137 |
func (wc *WC) Sync() (chan int, bool) {
|
|
138 |
return wc.wsync, (wc.C & DSyncWidth) != 0
|
| 139 | 139 |
}
|
| 140 | 140 |
|
| 141 | 141 |
// OnComplete returns decorator, which wraps provided decorator, with
|