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

msg/async: avoid atomic variable overhead #12809

Merged
merged 1 commit into from Jan 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/msg/async/Stack.cc
Expand Up @@ -174,7 +174,7 @@ void NetworkStack::stop()
class C_drain : public EventCallback {
Mutex drain_lock;
Cond drain_cond;
std::atomic<unsigned> drain_count;
unsigned drain_count;

public:
explicit C_drain(size_t c)
Expand All @@ -183,11 +183,11 @@ class C_drain : public EventCallback {
void do_request(int id) {
Mutex::Locker l(drain_lock);
drain_count--;
drain_cond.Signal();
if (drain_count == 0) drain_cond.Signal();
}
void wait() {
Mutex::Locker l(drain_lock);
while (drain_count.load())
while (drain_count)
drain_cond.Wait(drain_lock);
}
};
Expand Down