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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user