-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add blocking counter #7000
Conversation
paddle/framework/blocking_counter.h
Outdated
void Wait() { | ||
if (cnt_ == 0) return; | ||
std::unique_lock<std::mutex> lock(done_m); | ||
done_cv.wait(lock, [=] { return done_ == 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.
Just wait for cnt_ == 0
condition, then done_
is not needed.
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.
Done.
paddle/framework/blocking_counter.h
Outdated
*/ | ||
void DecreaseCount() { | ||
cnt_.fetch_sub(1); | ||
if (cnt_ != 0) return; |
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.
Use if (cnt_-- !=0)
is simpler.
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, simpler is great, and I think if (cnt_-- != 1)
is correct.
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.
Done.
No need this feature, close this PR. |
Fixed #6999