Closed tsingson closed 5 years ago
@tsingson Thanks for your contribution! The example code you provide is correct and well-formatted, but I think it's a little complicated.
While using the same library (here is timingwheel
), different users have different use-cases and different opinions about how to structure their code. For simplicity, I think the examples of timingwheel
should try to avoid:
goInternalTimer()
, or continuously printing out the current time in for i := 1; i <= MainGoroutineWait; i++
loop.tw
, taskChannel
and tl
, and initializing them within init()
, or defining many small functions such as timingwheelTaskTriggerFunc()
, timingWheelTaskRunner()
, goInternalTimerTaskRunner()
and goInternalTimer()
. In other words, being a basic library, timingwheel
should provide examples as concentrated (also simple) as possible, just like what most standard Go libraries do.
So if I understand your example code correctly, the core snippet that is concentrated on how to use timingwheel
is mostly the same with the first example (i.e. Example (AddTimer)
) provided in Godoc?
Thank you for your quick response.
Yes, my example is a bit complicated and not easy to understand. Perhaps this is related to personal coding habits.
add example