go
go copied to clipboard
my golang lib
Fix #9. Signed-off-by: Robert-André Mauchin
``` tv[i] = append(tv[i], t) t.vec = tv[i] t.index = len(tv[i]) - 1 ``` 以前默认创建的 128 大小的 []_timer 数组,如果超过 128 大小后,append 内部会生成新的 []_timer 数组,导致之前 _timer 引用的 []_timer 中 index 位置不一定为正确的...
https://github.com/siddontang/go/blob/2b7082d296ba89ae7ead0f977816bddefb65df9d/time2/wheel.go#L148 https://github.com/siddontang/go/blob/2b7082d296ba89ae7ead0f977816bddefb65df9d/time2/wheel.go#L154 https://github.com/siddontang/go/blob/2b7082d296ba89ae7ead0f977816bddefb65df9d/time2/wheel.go#L112
cb568a3e5cc06256f91a2da5a87455f717eb33f4 does not pass unit tests with Go 1.10. At least: ``` Testing: "/builddir/build/BUILD/go-cb568a3e5cc06256f91a2da5a87455f717eb33f4/_build/src/github.com/siddontang/go/filelock" + GOPATH=/builddir/build/BUILD/go-cb568a3e5cc06256f91a2da5a87455f717eb33f4/_build:/usr/share/gocode + go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro '\''' # github.com/siddontang/go/filelock ./file_lock_test.go:43:...
siddontang,在查看你的时间轮代码时候,觉得(TimingWheel)After()函数中index计算不正确,为了验证猜想,我写了如下测试用例: - https://github.com/AlexStocks/go-practice/blob/master/time/siddontang_time_wheel.go 输出是:expect time cost 100s, while real time cost is 110 s. 显然,当运行次数越多,你的timingwheel的时间误差将越多,我给你修正后的(TimingWheel)After()函数代码如下: func (w *TimingWheel) After(timeout time.Duration) = w.maxTimeout { panic("timeout too much, over maxtimeout") } ```...
run following command and test case is not passed ``` go test ./... -test.v -test.cpu=1,2,4 go test ./... -test.v -test.short -test.race ```