github.com/benz9527/toy-box/algo@v0.0.0-20240221120937-66c0c6bd5abd/queue/ring_buffer_intf.go (about)

     1  package queue
     2  
     3  type RingBufferEntry[T any] interface {
     4  	GetValue() T
     5  	GetCursor() uint64
     6  	Store(cursor uint64, value T)
     7  }
     8  
     9  type RingBuffer[T any] interface {
    10  	Capacity() uint64
    11  	LoadEntryByCursor(cursor uint64) RingBufferEntry[T]
    12  }
    13  
    14  type RingBufferCursor interface {
    15  	Next() uint64
    16  	NextN(n uint64) uint64
    17  	Load() uint64
    18  	CAS(old, new uint64) bool
    19  }