1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

fix: fix OrDone func

This commit is contained in:
dudaodong
2022-04-21 14:19:38 +08:00
parent c27ccad2b9
commit 9444582e44

View File

@@ -222,11 +222,11 @@ func (c *Channel) Or(channels ...<-chan any) <-chan any {
// OrDone
func (c *Channel) OrDone(ctx context.Context, channel <-chan any) <-chan any {
resStream := make(chan any)
valStream := make(chan any)
go func() {
defer close(resStream)
defer close(valStream)
for {
select {
case <-ctx.Done():
return
@@ -235,11 +235,13 @@ func (c *Channel) OrDone(ctx context.Context, channel <-chan any) <-chan any {
return
}
select {
case resStream <- v:
case valStream <- v:
case <-ctx.Done():
}
}
}
}()
return resStream
return valStream
}