feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
committed by
GitHub
parent
b5015ec7b9
commit
447a51f08b
38
vendor/sigs.k8s.io/controller-runtime/pkg/internal/syncs/syncs.go
generated
vendored
Normal file
38
vendor/sigs.k8s.io/controller-runtime/pkg/internal/syncs/syncs.go
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// MergeChans returns a channel that is closed when any of the input channels are signaled.
|
||||
// The caller must call the returned CancelFunc to ensure no resources are leaked.
|
||||
func MergeChans[T any](chans ...<-chan T) (<-chan T, context.CancelFunc) {
|
||||
var once sync.Once
|
||||
out := make(chan T)
|
||||
cancel := make(chan T)
|
||||
cancelFunc := func() {
|
||||
once.Do(func() {
|
||||
close(cancel)
|
||||
})
|
||||
<-out
|
||||
}
|
||||
cases := make([]reflect.SelectCase, len(chans)+1)
|
||||
for i := range chans {
|
||||
cases[i] = reflect.SelectCase{
|
||||
Dir: reflect.SelectRecv,
|
||||
Chan: reflect.ValueOf(chans[i]),
|
||||
}
|
||||
}
|
||||
cases[len(cases)-1] = reflect.SelectCase{
|
||||
Dir: reflect.SelectRecv,
|
||||
Chan: reflect.ValueOf(cancel),
|
||||
}
|
||||
go func() {
|
||||
defer close(out)
|
||||
_, _, _ = reflect.Select(cases)
|
||||
}()
|
||||
|
||||
return out, cancelFunc
|
||||
}
|
||||
Reference in New Issue
Block a user