Fix reference assembly.
[lightning.git] / throttle.go
index da338f62f5ed0857f35497ae26a04e8082e3ca24..ce3279dd3398d76886c9f40cb2c279114d08d205 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Lightning Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
 package lightning
 
 import (
@@ -40,3 +44,15 @@ func (t *throttle) Wait() error {
        t.wg.Wait()
        return t.Err()
 }
+
+func (t *throttle) Go(f func() error) error {
+       t.Acquire()
+       if t.Err() != nil {
+               return t.Err()
+       }
+       go func() {
+               t.Report(f())
+               t.Release()
+       }()
+       return nil
+}