Composite is a touch faster when it's an alias for an array of Cursor pointers.
diff --git a/composite_barrier.go b/composite_barrier.go
index 30799d2..80c12bd 100644
--- a/composite_barrier.go
+++ b/composite_barrier.go
@@ -1,23 +1,26 @@
package disruptor
-// performance TODO: type CompositeBarrier []*Cursor
-type CompositeBarrier struct {
- cursors []*Cursor
-}
+type CompositeBarrier []*Cursor
-func NewCompositeBarrier(upstream ...*Cursor) *CompositeBarrier {
+// type CompositeBarrier struct {
+// cursors []*Cursor
+// }
+
+func NewCompositeBarrier(upstream ...*Cursor) CompositeBarrier {
if len(upstream) == 0 {
panic("At least one upstream cursor is required.")
}
cursors := make([]*Cursor, len(upstream))
copy(cursors, upstream)
- return &CompositeBarrier{cursors}
+ // return &CompositeBarrier{cursors}
+ return CompositeBarrier(cursors)
}
-func (this *CompositeBarrier) Read(noop int64) int64 {
+func (this CompositeBarrier) Read(noop int64) int64 {
minimum := MaxSequenceValue
- for _, item := range this.cursors {
+ // for _, item := range this.cursors {
+ for _, item := range this {
sequence := item.Load()
if sequence < minimum {
minimum = sequence