采用自动调度器运转时间轮
(t *testing.T)
| 51 | |
| 52 | // 采用自动调度器运转时间轮 |
| 53 | func TestNewAutoExecTimerScheduler(t *testing.T) { |
| 54 | autoTS := NewAutoExecTimerScheduler() |
| 55 | |
| 56 | //给调度器添加Timer |
| 57 | for i := 0; i < 2000; i++ { |
| 58 | f := NewDelayFunc(foo, []interface{}{i, i * 3}) |
| 59 | tID, err := autoTS.CreateTimerAfter(f, time.Duration(3*i)*time.Millisecond) |
| 60 | if err != nil { |
| 61 | zlog.Error("create timer error", tID, err) |
| 62 | break |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | //阻塞等待 |
| 67 | select {} |
| 68 | } |
| 69 | |
| 70 | // 测试取消一个定时器 |
| 71 | func TestCancelTimerScheduler(t *testing.T) { |
nothing calls this directly
no test coverage detected