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 auto lock class #7244

Closed
wants to merge 9 commits into from
Closed

add auto lock class #7244

wants to merge 9 commits into from

Conversation

muleisheng
Copy link
Contributor

No description provided.

@xiaoxq
Copy link
Contributor

xiaoxq commented Mar 13, 2019

What is the usage?

@muleisheng
Copy link
Contributor Author

What is the usage?

I have added logic to use this auto lock.

@muleisheng muleisheng requested a review from xiaoxq March 14, 2019 08:39
modules/common/util/auto_lock.h Outdated Show resolved Hide resolved
modules/common/util/auto_lock.h Outdated Show resolved Hide resolved
modules/common/util/auto_lock_test.cc Outdated Show resolved Hide resolved

~AutoLock() {
UnLock();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try std::lock_guard? It's pretty similar with your implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto_lock supplies unlock by manual when we need.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I prefer a scoped lock_guard in such case. It's pretty straight forward and easy to understand by everybody.

@xiaoxq xiaoxq requested review from siyangy and ycool March 19, 2019 03:42
@muleisheng muleisheng closed this Mar 21, 2019
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.

3 participants