projects
/
lightning.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix namespace types.
[lightning.git]
/
throttle.go
diff --git
a/throttle.go
b/throttle.go
index a8411001099fdc8c3d068c7bd4133a24dd968416..ce3279dd3398d76886c9f40cb2c279114d08d205 100644
(file)
--- a/
throttle.go
+++ b/
throttle.go
@@
-1,4
+1,8
@@
-package main
+// Copyright (C) The Lightning Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+package lightning
import (
"sync"
import (
"sync"
@@
-40,3
+44,15
@@
func (t *throttle) Wait() error {
t.wg.Wait()
return t.Err()
}
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
+}