-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
light: use atomic type #27169
light: use atomic type #27169
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.
LGTM
light/lightchain.go
Outdated
@@ -302,7 +302,7 @@ func (lc *LightChain) GetBlockByNumber(ctx context.Context, number uint64) (*typ | |||
// Stop stops the blockchain service. If any imports are currently in progress | |||
// it will abort them using the procInterrupt. | |||
func (lc *LightChain) Stop() { | |||
if !atomic.CompareAndSwapInt32(&lc.running, 0, 1) { | |||
if !lc.running.CompareAndSwap(false, true) { |
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.
This variable name is weird. Perhaps stopped is more suitable.
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.
Thanks for the reminder, it has been modified.
* light: use atomic type * light: use a suitable name for the stopped switch in LightChain
* light: use atomic type * light: use a suitable name for the stopped switch in LightChain
This reverts commit 422f4b4.
This reverts commit 422f4b4.
use atomic.Bool for switches in light.LightChain