From dbe06551b86460d5ebf18ee33218cd6d11cd07e4 Mon Sep 17 00:00:00 2001 From: Abhinav Arora Date: Fri, 2 Feb 2018 16:12:53 -0800 Subject: [PATCH] Channel should notify both condition variables on close --- paddle/framework/details/buffered_channel.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/paddle/framework/details/buffered_channel.h b/paddle/framework/details/buffered_channel.h index b093e158929..9c806461aa5 100644 --- a/paddle/framework/details/buffered_channel.h +++ b/paddle/framework/details/buffered_channel.h @@ -49,6 +49,7 @@ class Buffered : public paddle::framework::Channel { } void NotifyAllSenders(std::unique_lock*); + void NotifyAllParticipants(std::unique_lock*); }; template @@ -80,7 +81,7 @@ template void Buffered::Close() { std::unique_lock lock(mu_); closed_ = true; - NotifyAllSenders(&lock); + NotifyAllParticipants(&lock); } template @@ -88,7 +89,7 @@ Buffered::~Buffered() { std::unique_lock lock(mu_); closed_ = true; channel_.clear(); - NotifyAllSenders(&lock); + NotifyAllParticipants(&lock); } template @@ -97,6 +98,13 @@ void Buffered::NotifyAllSenders(std::unique_lock* lock) { full_cond_var_.notify_all(); } +template +void Buffered::NotifyAllParticipants(std::unique_lock* lock) { + lock->unlock(); + full_cond_var_.notify_all(); + empty_cond_var_.notify_all(); +} + } // namespace details } // namespace framework } // namespace paddle -- GitLab