use time.Timer

This commit is contained in:
Song Gao 2015-11-11 22:12:44 +00:00
parent 965ca414a6
commit d8e4f41ac8

View file

@ -11,13 +11,6 @@ import (
const BUFFERSIZE = 1522 const BUFFERSIZE = 1522
func startTimeout(ch chan<- bool, t time.Duration) {
go func() {
time.Sleep(t)
ch <- true
}()
}
func startRead(ch chan<- []byte, ifce *Interface) { func startRead(ch chan<- []byte, ifce *Interface) {
go func() { go func() {
for { for {
@ -54,8 +47,7 @@ func TestBroadcast(t *testing.T) {
dataCh := make(chan []byte, 8) dataCh := make(chan []byte, 8)
startRead(dataCh, ifce) startRead(dataCh, ifce)
timeout := make(chan bool, 1) timeout := time.NewTimer(8 * time.Second).C
startTimeout(timeout, time.Second*8)
readFrame: readFrame:
for { for {