From 1008f05277d6ee6fc80730ca2d6b55454d2b5f81 Mon Sep 17 00:00:00 2001 From: mooncake9527 Date: Thu, 9 Jan 2025 16:15:34 +0800 Subject: [PATCH] not block in the first chan --- concurrency/channel.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/concurrency/channel.go b/concurrency/channel.go index c6109710..5b7e24ee 100644 --- a/concurrency/channel.go +++ b/concurrency/channel.go @@ -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(): + } } - } + }() } }()