-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: timer reset #51
fix: timer reset #51
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそうです
if !t.timer.Stop() { | ||
select { // cleanup | ||
case <-t.timer.C: | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default はあまり意味はないですか?
if !..Stop() 句で入っている時点で必ず timer.C から読み出せる?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
関連するIssue等を読み直してみましたが、確かに Stop()==false の時点で(かつTimerの受信側のgoroutineのselectで読み出しする場合)必ず読み出せるようです。(ややこしい、、)
golang/go#27169
コメントを残して不要な処理を削除するか、分かりやすさを重視してこのままで行くか、どちらがいいでしょう?(迷い中)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このままでいいかと思います。
select ... default 句は golang のイディオム的な意味合いも強そうなので、意図がわからないということもなさそうですので。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Proposal
、Timer通知をそれぞれ独立したgoroutineで行うように修正