fix test case broadcast

master 0.0.1-alpha6
codeskyblue 8 years ago
parent 76e5617248
commit e9ea58aa1b

@ -53,7 +53,7 @@ func (b *BroadcastString) AddListener(c chan string) chan string {
b.mu.Lock()
defer b.mu.Unlock()
if c == nil {
c = make(chan string, 0)
c = make(chan string, 4)
}
b.writers[c] = true
return c

@ -3,11 +3,13 @@ package main
import (
"sync"
"testing"
"time"
)
func TestBroadcast(t *testing.T) {
bs := NewBroadcastString()
bs.WriteMessage("hello")
time.Sleep(10 * time.Millisecond)
c1 := bs.AddListener(nil)
go func() {
bs.WriteMessage("world")

Loading…
Cancel
Save