Results 71 comments of Luo Peng

@lonerwolf 你好,方便贴一下可以复现问题的最小完整代码,以及完整的报错信息吗?另外代码的运行环境是怎样的?

从你给的报错信息来看,出现 panic 的 goroutine 是由 addOrRun 创建的,但是 "invalid memory address or nil pointer dereference" 这个 error 发生在 goroutine 内部的这一行: > github.com/lonerwolf/danyun-service/server.(*ClientSession).GetMessage.func2() /home/lonerwolf/danyun-service/server/client_session.go:71 +0x45 初步怀疑是传入的处理函数 f 内部的 `session.conn` 或者 `session.SessionID` 存在问题?

@lonerwolf 据我所知,Go 的调用栈信息是由近及远的(即越往下离错误越远),参考示例 https://play.golang.org/p/SulKU12FkgF

可以复用同一个 TimingWheel,我在这里 https://github.com/RussellLuo/timingwheel/issues/1#issuecomment-428177704 也有回答过。

> 比如想开间隔多少秒执行一次的任务,间隔多少小时执行一次任务,间隔多少天执行,是否需要分别创建不同tick,不同wheel的TimingWheel对象 @jp3411952 - 按照你的描述,应该是可以用同一个时间轮的,可以参考 [这个例子](https://github.com/RussellLuo/timingwheel/issues/19#issuecomment-608963673) - 关于 tick 和 wheelSize 的选取,参考这里的说明:https://github.com/RussellLuo/timingwheel/issues/4#issuecomment-470943484

感谢 @tobyzxj 帮忙回复! > 添加task的时候直接追加的数组尾部, 到期时直接遍历数组取出所有task. 我稍微补充一下: 1. 数组扩容时会 copy 数据,不如链表高效 2. timer.Stop() 可能会从任意位置删除元素,链表最适合这种操作

@welllog 谢谢反馈! > 1. DelayQueue poll退出时需要清理wakeupC,不然offer会卡住吧 > 2. 在bucket的Flush函数中会首先移除该bucket中的timer,移除后再添加到新的bucket中或执行,此时在还未加到新bucket时如果并发的对某个timer stop,因为timer的bucket为nil,导致并没有停止 你提到的两个问题确实存在。 第二个问题: - 是由 #28 引入的,这个 PR 为了解决死锁问题,打破了 “b.remove() + b.Add()(由 reinsert 间接调用)” 的原子性;@yunlong0928 提到的 TODO 注释,也是在这个 PR 中加的。 -...

@yunlong0928 我修复了 bucket.Flush 函数,并加了一些注释说明: https://github.com/RussellLuo/timingwheel/blob/54845bda31084d50d98d83afb01bd89d48154668/bucket.go#L123-L127 > 在bucket的Flush函数中会首先移除该bucket中的timer,移除后再添加到新的bucket中或执行,此时在还未加到新bucket时如果并发的对某个timer stop,因为timer的bucket为nil,导致并没有停止 @welllog 修复以后,这个问题应该不存在了。

Hi @reddec > So I suspect that the number of goroutines will be roughly equal to the number of limiters Yes, you are right. > Is it possible to use...

Per the current implementation: https://github.com/traefik/yaegi/blob/f76db27c770599da3cffc0a7553f8e1403bb23f8/interp/type.go#L427-L434 I guess this might be a possible fix: ```diff case v.IsValid(): // Size if defined by a constant litteral value. - if isConstantValue(v.Type()) { -...