mirror of
https://github.com/fatedier/frp.git
synced 2026-01-11 22:23:12 +00:00
cleanup code (#4019)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user