Commit a06ff797 authored by wongoo's avatar wongoo

remove unused code

parent 971212c5
......@@ -39,19 +39,16 @@ func NewWheel(span time.Duration, buckets int) *Wheel {
period: span * (time.Duration(buckets)),
ticker: time.NewTicker(span),
index: 0,
ring: make([](chan struct{}), buckets),
ring: make([]chan struct{}, buckets),
now: time.Now(),
}
go func() {
var notify chan struct{}
// var cw CountWatch
// cw.Start()
for t := range w.ticker.C {
w.Lock()
w.now = t
// fmt.Println("index:", w.index, ", value:", w.bitmap.Get(w.index))
notify = w.ring[w.index]
w.ring[w.index] = nil
w.index = (w.index + 1) % len(w.ring)
......@@ -62,7 +59,6 @@ func NewWheel(span time.Duration, buckets int) *Wheel {
close(notify)
}
}
// fmt.Println("timer costs:", cw.Count()/1e9, "s")
}()
return w
......@@ -87,7 +83,6 @@ func (w *Wheel) After(timeout time.Duration) <-chan struct{} {
if w.ring[pos] == nil {
w.ring[pos] = make(chan struct{})
}
// fmt.Println("pos:", pos)
c := w.ring[pos]
w.Unlock()
......
......@@ -24,13 +24,11 @@ func TestWheel(t *testing.T) {
cw.Start()
for {
select {
case <-wheel.After(TimeMillisecondDuration(1000)):
fmt.Println("loop:", index)
index++
if index >= 150 {
return
}
<-wheel.After(TimeMillisecondDuration(1000))
fmt.Println("loop:", index)
index++
if index >= 150 {
return
}
}
}
......@@ -54,13 +52,11 @@ func TestWheels(t *testing.T) {
defer wg.Done()
var index int
for {
select {
case <-wheel.After(d):
fmt.Println("loop:", index, ", interval:", d)
index++
if index >= 100 {
return
}
<-wheel.After(d)
fmt.Println("loop:", index, ", interval:", d)
index++
if index >= 100 {
return
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment