Skip to content
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

add lock for value operation. #359

Closed
wants to merge 1 commit into from
Closed

Conversation

zhanglp92
Copy link

When I concurrent running program, has some wrong. I don‘t use metex with my code.
I think locks should be added here.

@metalmatze
Copy link
Member

Is this still necessary when using atomic 🤔

@grobie
Copy link
Member

grobie commented Nov 9, 2017

No. client_golang is concurrency safe and uses the atomic package to reduce the footprint. Mutex are not only unnecessary here, they would incur a huge performance penalty.

Björn gave a talk explaining the design at the GopherCon 2015, here are the slides.

@beorn7
Copy link
Member

beorn7 commented Nov 9, 2017

The only concurrency issue I know of is #275 (for which I have a solution in my head, I just need to find time to write it down).

@beorn7 beorn7 closed this Nov 9, 2017
@zhanglp92
Copy link
Author

If you do not use the lock, there will be concurrency issue.
eg: I concurrent implementation of the program.

func test() {
gauge.Inc()
defer gauge.Dec()
}

image

@beorn7
Copy link
Member

beorn7 commented Nov 10, 2017

Could you provide the full code to replicate the problem? The above is not sufficient to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants