diff --git a/bar.go b/bar.go index c6cecc0..f0f3d61 100644 --- a/bar.go +++ b/bar.go @@ -366,14 +366,14 @@ columns := make([]chan int, 0, len(s.pDecorators)+len(s.aDecorators)) var pCount int for _, d := range s.pDecorators { - if ok, ch := d.Syncable(); ok { + if ch, ok := d.Sync(); ok { columns = append(columns, ch) pCount++ } } var aCount int for _, d := range s.aDecorators { - if ok, ch := d.Syncable(); ok { + if ch, ok := d.Sync(); ok { columns = append(columns, ch) aCount++ } diff --git a/decor/decorator.go b/decor/decorator.go index cdbe1ea..fa7c994 100644 --- a/decor/decorator.go +++ b/decor/decorator.go @@ -55,15 +55,15 @@ // A decorator must implement this interface, in order to be used with // mpb library. type Decorator interface { + Synchronizer Decor(*Statistics) string - Syncable } -// Syncable interface. -// All decorators implement this interface implicitly. Its Syncable +// Synchronizer interface. +// All decorators implement this interface implicitly. Its Sync // method exposes width sync channel, if sync is enabled. -type Syncable interface { - Syncable() (bool, chan int) +type Synchronizer interface { + Sync() (chan int, bool) } // OnCompleteMessenger interface. @@ -97,7 +97,7 @@ // WC is a struct with two public fields W and C, both of int type. // W represents width and C represents bit set of width related config. -// A decorator should embed WC, in order to become Syncable. +// A decorator should embed WC, to enable width synchronization. type WC struct { W int C int @@ -134,9 +134,9 @@ } } -// Syncable is implementation of Syncable interface. -func (wc *WC) Syncable() (bool, chan int) { - return (wc.C & DSyncWidth) != 0, wc.wsync +// Sync is implementation of Synchronizer interface. +func (wc *WC) Sync() (chan int, bool) { + return wc.wsync, (wc.C & DSyncWidth) != 0 } // OnComplete returns decorator, which wraps provided decorator, with diff --git a/decorators_test.go b/decorators_test.go index a951389..aebd06d 100644 --- a/decorators_test.go +++ b/decorators_test.go @@ -211,7 +211,7 @@ func toSyncMatrix(ss []step) map[int][]chan int { var column []chan int for _, s := range ss { - if ok, ch := s.decorator.Syncable(); ok { + if ch, ok := s.decorator.Sync(); ok { column = append(column, ch) } }