sequence.go 555 B

123456789101112131415161718192021222324
  1. package dbus
  2. // Sequence represents the value of a monotonically increasing counter.
  3. type Sequence uint64
  4. const (
  5. // NoSequence indicates the absence of a sequence value.
  6. NoSequence Sequence = 0
  7. )
  8. // sequenceGenerator represents a monotonically increasing counter.
  9. type sequenceGenerator struct {
  10. nextSequence Sequence
  11. }
  12. func (generator *sequenceGenerator) next() Sequence {
  13. result := generator.nextSequence
  14. generator.nextSequence++
  15. return result
  16. }
  17. func newSequenceGenerator() *sequenceGenerator {
  18. return &sequenceGenerator{nextSequence: 1}
  19. }