Repository: kubernetes/kubernetes
File: staging/src/k8s.io/client-go/tools/cache/the_real_fifo.go (Go)

Code before:
	// keyFunc is used to make the key used for queued item insertion and retrieval, and
	// should be deterministic.
	keyFunc KeyFunc

	// knownObjects list keys that are "known" --- affecting Delete(),
	// Replace(), and Resync().
	// It is nil if emitAtomicEvents is true.
	knownObjects KeyListerGetter

	// Indication the queue is closed.
	// Used to indicate a queue is closed so a control loop can exit when a queue is empty.
	// Currently, not used to gate any of CRUD operations.
	closed bool

	// Called with every object if non-nil.
	transformer TransformFunc

	// batchSize determines the maximum number of objects we can combine into a batch.
	batchSize int

	// emitAtomicEvents defines whether events like Replace and Resync should be emitted
	// atomically rather than as a series of events. This means that any call to the FIFO
	// will emit a single event.
	// If it is set:
	// * a single ReplacedList event will be emitted instead of multiple Replace events
	// * a single SyncKnown event will be emitted instead of multiple Sync events
	emitAtomicEvents bool
}

type ReplacedListInfo struct {
	ResourceVersion string
	Objects         []interface{}
}

var (
	_ = Queue(&RealFIFO{})             // RealFIFO is a Queue
	_ = TransformingStore(&RealFIFO{}) // RealFIFO implements TransformingStore to allow memory optimizations
)

// Close the queue.
func (f *RealFIFO) Close() {
	f.lock.Lock()
	defer f.lock.Unlock()
	f.closed = true
	f.cond.Broadcast()
}

// KeyOf exposes f's keyFunc, but also detects the key of a Deltas object or
// DeletedFinalStateUnknown objects.
func (f *RealFIFO) keyOf(obj interface{}) (string, error) {
	if d, ok := obj.(Deltas); ok {

Review comment (suggestion):
```suggestion
	// * a single ReplacedAll event will be emitted instead of multiple Replace events
	// * a single SyncAll event will be emitted instead of multiple Sync events
```

Code after:
	// keyFunc is used to make the key used for queued item insertion and retrieval, and
	// should be deterministic.
	keyFunc KeyFunc

	// knownObjects list keys that are "known" --- affecting Delete(),
	// Replace(), and Resync().
	// It is nil if emitAtomicEvents is true.
	knownObjects KeyListerGetter

	// Indication the queue is closed.
	// Used to indicate a queue is closed so a control loop can exit when a queue is empty.
	// Currently, not used to gate any of CRUD operations.
	closed bool

	// Called with every object if non-nil.
	transformer TransformFunc

	// batchSize determines the maximum number of objects we can combine into a batch.
	batchSize int

	// emitAtomicEvents defines whether events like Replace and Resync should be emitted
	// atomically rather than as a series of events. This means that any call to the FIFO
	// will emit a single event.
	// If it is set:
	// * a single ReplacedAll event will be emitted instead of multiple Replace events
	// * a single SyncAll event will be emitted instead of multiple Sync events
	emitAtomicEvents bool
}

// ReplacedAllInfo is the object associated with a Delta of type=ReplacedAll
type ReplacedAllInfo struct {
	// ResourceVersion is the resource version passed to the Replace() call that created this Delta
	ResourceVersion string
	// Objects are the list of objects passed to the Replace() call that created this Delta,
	// with any configured transformation already applied.
	Objects []interface{}
}

// SyncAllInfo is the object associated with a Delta of type=SyncAll
// It is used to trigger a resync of the entire queue.
type SyncAllInfo struct{}

var (
	_ = Queue(&RealFIFO{})             // RealFIFO is a Queue
	_ = TransformingStore(&RealFIFO{}) // RealFIFO implements TransformingStore to allow memory optimizations
)

// Close the queue.
func (f *RealFIFO) Close() {
	f.lock.Lock()
	defer f.lock.Unlock()