Skip to content

Commit

Permalink
not block in the first chan
Browse files Browse the repository at this point in the history
  • Loading branch information
mooncake9527 committed Jan 9, 2025
1 parent d4b425e commit 1008f05
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions concurrency/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,14 @@ func (c *Channel[T]) Bridge(ctx context.Context, chanStream <-chan <-chan T) <-c
return
}

for val := range c.OrDone(ctx, stream) {
select {
case valStream <- val:
case <-ctx.Done():
go func() {
for val := range c.OrDone(ctx, stream) {
select {
case valStream <- val:
case <-ctx.Done():
}
}
}
}()
}
}()

Expand Down

0 comments on commit 1008f05

Please sign in to comment.