blob: dbdd5432719722588d3615ca32495086a8360c6a [file] [log] [blame]
package disruptor
type CompositeBarrier struct {
cursors []*Cursor
}
func NewCompositeBarrier(upstream ...*Cursor) *CompositeBarrier {
cursors := make([]*Cursor, len(upstream))
copy(cursors, upstream)
return &CompositeBarrier{cursors}
}
func (this *CompositeBarrier) LoadBarrier(current int64) int64 {
minimum := MaxSequenceValue
for _, item := range this.cursors {
sequence := item.Load()
if sequence < minimum {
minimum = sequence
}
}
return minimum
}