1
0
mirror of https://github.com/siddontang/go.git synced 2025-04-27 13:48:51 +08:00
siddontang.golib/timingwheel/timingwheel_test.go
2014-03-28 14:11:28 +08:00

35 lines
474 B
Go

package timingwheel
import (
"testing"
"time"
)
func TestTimingWheel(t *testing.T) {
w := NewTimingWheel(1*time.Second, 10)
println(time.Now().Unix())
for {
select {
case <-w.After(1 * time.Second):
println(time.Now().Unix())
return
}
}
}
func TestTask(t *testing.T) {
w := NewTimingWheel(1*time.Second, 10)
r := make(chan struct{})
f := func() {
println("hello world")
r <- struct{}{}
}
w.AddTask(1*time.Second, f)
<-r
println("over")
}