github.com/benz9527/toy-box/algo@v0.0.0-20240221120937-66c0c6bd5abd/pubsub/x_sequencer.go (about) 1 package pubsub 2 3 import ( 4 "github.com/benz9527/toy-box/algo/queue" 5 ) 6 7 type xSequencer struct { 8 writeCursor queue.RingBufferCursor // concurrent write 9 readCursor queue.RingBufferCursor // concurrent read 10 capacity uint64 11 } 12 13 func NewXSequencer(capacity uint64) Sequencer { 14 return &xSequencer{ 15 capacity: capacity, 16 readCursor: queue.NewXRingBufferCursor(), 17 writeCursor: queue.NewXRingBufferCursor(), 18 } 19 } 20 21 func (x *xSequencer) GetReadCursor() queue.RingBufferCursor { 22 return x.readCursor 23 } 24 25 func (x *xSequencer) Capacity() uint64 { 26 return x.capacity 27 } 28 29 func (x *xSequencer) GetWriteCursor() queue.RingBufferCursor { 30 return x.writeCursor 31 } 32 33 type xSequenceReconciler struct { 34 }