arikawa/gateway/sequence.go

15 lines
268 B
Go
Raw Normal View History

2020-01-15 04:43:34 +00:00
package gateway
import "sync/atomic"
type Sequence struct {
2020-01-15 04:56:50 +00:00
seq int64
2020-01-15 04:43:34 +00:00
}
func NewSequence() Sequence {
2020-01-15 04:56:50 +00:00
return Sequence{0}
2020-01-15 04:43:34 +00:00
}
2020-01-15 04:56:50 +00:00
func (s *Sequence) Set(seq int64) { atomic.StoreInt64(&s.seq, seq) }
func (s *Sequence) Get() int64 { return atomic.LoadInt64(&s.seq) }