1// Copyright 2021 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package a 6 7import "sync" 8 9type Loader[K comparable, R any] struct { 10 batch *LoaderBatch[K, R] 11} 12 13func (l *Loader[K, R]) Load() error { 14 l.batch.f() 15 return nil 16} 17 18type LoaderBatch[K comparable, R any] struct { 19 once *sync.Once 20} 21 22func (b *LoaderBatch[K, R]) f() { 23 b.once.Do(func() {}) 24} 25