You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the task is triggered twice in one ticker, then it prints "=============== retry ====>" and exits the program later.
You will see output similars to the following output:
=============== retry ====>cost(tick:2s+after:1s): 5.000353629s 5.424µs
If in tw.putCircle the insert index equals tw.currentIndex, then we insert a task in map when iterates the map.
Because golang iterates map starting at any position randomly, then we maybe iterate the new inserted value in the iteration loop.
It maybe trigger more times than once.
If the task is triggered twice in one ticker, then it prints "=============== retry ====>" and exits the program later.
You will see output similars to the following output:
=============== retry ====>cost(tick:2s+after:1s): 5.000353629s 5.424µs
We can run it in https://go.dev/tour/welcome/1.
We maybe see the output
cost(tick:2s+after:1s): 13s 2s cost(tick:2s): 3s cost(tick:2s+after:1s): 15s 2s =============== retry ====>cost(tick:2s+after:1s): 15s 0s cost(tick:2s): 3s
or
cost(tick:1s+after:1s): 2s cost(tick:2s+after:1s): 3s 3s =============== retry ====>cost(tick:2s+after:1s): 3s 0s cost(tick:2s+after:1s): 5s 2s cost(tick:2s): 3s
The cause for it:
In func (tw *TimeWheel) handleTick(),
If in tw.putCircle the insert index equals tw.currentIndex, then we insert a task in map when iterates the map.
Because golang iterates map starting at any position randomly, then we maybe iterate the new inserted value in the iteration loop.
It maybe trigger more times than once.
How to resolve it?
Then you can run the previous main function will not exit for very long time until you kill it forcefully.
The text was updated successfully, but these errors were encountered: