aboutsummaryrefslogtreecommitdiffstats
path: root/broadcast.go
diff options
context:
space:
mode:
Diffstat (limited to 'broadcast.go')
-rw-r--r--broadcast.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/broadcast.go b/broadcast.go
index 7268971..9ad47f9 100644
--- a/broadcast.go
+++ b/broadcast.go
@@ -13,15 +13,15 @@ type Broadcast[T any] struct {
// The caller is responsible for closing source. When source is closed,
// Broadcast will close all destinations.
-func NewBroadcast[T any](source chan T) Broadcast[T] {
- bc := Broadcast[T]{
+func NewBroadcast[T any](source chan T) *Broadcast[T] {
+ bc := &Broadcast[T]{
source,
make([]chan<- T, 0),
sync.Mutex{},
sync.WaitGroup{},
}
- go func(bc *Broadcast[T]) {
+ go func() {
bc.wg.Add(1)
for v := range bc.source {
@@ -39,7 +39,7 @@ func NewBroadcast[T any](source chan T) Broadcast[T] {
bc.mu.Unlock()
bc.wg.Done()
- }(&bc)
+ }()
return bc
}