1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
12 type throttle struct {
21 func (t *throttle) Acquire() {
22 t.setupOnce.Do(func() {
24 panic("throttle.Max < 1")
26 t.ch = make(chan bool, t.Max)
32 func (t *throttle) Release() {
37 func (t *throttle) Report(err error) {
39 t.errorOnce.Do(func() { t.err.Store(err) })
43 func (t *throttle) Err() error {
44 err, _ := t.err.Load().(error)
48 func (t *throttle) Wait() error {
53 func (t *throttle) Go(f func() error) error {