cleanup code (#4019)

This commit is contained in:
fatedier
2024-02-22 21:04:21 +08:00
committed by GitHub
parent 80cfd0938e
commit 7ae3719b82
9 changed files with 0 additions and 197 deletions

View File

@@ -16,7 +16,6 @@ package wait
import (
"math/rand"
"sync"
"time"
"github.com/fatedier/frp/pkg/util/util"
@@ -174,21 +173,3 @@ func Until(f func(), period time.Duration, stopCh <-chan struct{}) {
return period
}), true, stopCh)
}
func MergeAndCloseOnAnyStopChannel[T any](upstreams ...<-chan T) <-chan T {
out := make(chan T)
closeOnce := sync.Once{}
for _, upstream := range upstreams {
ch := upstream
go func() {
select {
case <-ch:
closeOnce.Do(func() {
close(out)
})
case <-out:
}
}()
}
return out
}