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 blocking counter #7000

Closed
wants to merge 2 commits into from

Conversation

Yancey1989
Copy link
Contributor

Fixed #6999

void Wait() {
if (cnt_ == 0) return;
std::unique_lock<std::mutex> lock(done_m);
done_cv.wait(lock, [=] { return done_ == true; });
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wait for cnt_ == 0 condition, then done_ is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

*/
void DecreaseCount() {
cnt_.fetch_sub(1);
if (cnt_ != 0) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use if (cnt_-- !=0) is simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, simpler is great, and I think if (cnt_-- != 1) is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@Yancey1989
Copy link
Contributor Author

Yancey1989 commented Mar 9, 2018

No need this feature, close this PR.

@Yancey1989 Yancey1989 closed this Mar 9, 2018
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