File: sequence.go

package info (click to toggle)
kitty 0.45.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,476 kB
  • sloc: ansic: 84,285; python: 57,992; objc: 5,432; sh: 1,333; xml: 364; makefile: 144; javascript: 78
file content (24 lines) | stat: -rw-r--r-- 555 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package dbus

// Sequence represents the value of a monotonically increasing counter.
type Sequence uint64

const (
	// NoSequence indicates the absence of a sequence value.
	NoSequence Sequence = 0
)

// sequenceGenerator represents a monotonically increasing counter.
type sequenceGenerator struct {
	nextSequence Sequence
}

func (generator *sequenceGenerator) next() Sequence {
	result := generator.nextSequence
	generator.nextSequence++
	return result
}

func newSequenceGenerator() *sequenceGenerator {
	return &sequenceGenerator{nextSequence: 1}
}