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 guard #865

Merged
merged 9 commits into from
Mar 3, 2017
Merged

Add lock guard #865

merged 9 commits into from
Mar 3, 2017

Conversation

yvxiang
Copy link
Collaborator

@yvxiang yvxiang commented Feb 28, 2017

(#622)

@yvxiang
Copy link
Collaborator Author

yvxiang commented Feb 28, 2017

build

4 similar comments
@yvxiang
Copy link
Collaborator Author

yvxiang commented Feb 28, 2017

build

@yvxiang
Copy link
Collaborator Author

yvxiang commented Feb 28, 2017

build

@yvxiang
Copy link
Collaborator Author

yvxiang commented Mar 1, 2017

build

@yvxiang
Copy link
Collaborator Author

yvxiang commented Mar 1, 2017

build


WriteLock::WriteLock(const std::string& file_path_a,
const std::string& file_path_b) {
int r = strcmp(file_path_a.c_str(),file_path_b.c_str());
Copy link
Collaborator

@bluebore bluebore Mar 1, 2017

Choose a reason for hiding this comment

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

这样写是不是好点

file_path_.push_back(file_path_a);
if (file_path_a != file_path_b) {
    file_path_.push_back(file_path_b);
    sort(file_path_.begin(), file_path_.end());
}
file_lock_manager_->Lock(file_path_[0]);
if (file_path_.size() == 2) {
    file_lock_manager_->Lock(file_path_[1]);
}

@bluebore bluebore merged commit bd60cf8 into baidu:master Mar 3, 2017
@yvxiang yvxiang deleted the lk_guard branch March 3, 2017 01:39
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.

2 participants