提交 dbe06551 编写于 作者: A Abhinav Arora

Channel should notify both condition variables on close

上级 d0599511
...@@ -49,6 +49,7 @@ class Buffered : public paddle::framework::Channel<T> { ...@@ -49,6 +49,7 @@ class Buffered : public paddle::framework::Channel<T> {
} }
void NotifyAllSenders(std::unique_lock<std::mutex>*); void NotifyAllSenders(std::unique_lock<std::mutex>*);
void NotifyAllParticipants(std::unique_lock<std::mutex>*);
}; };
template <typename T> template <typename T>
...@@ -80,7 +81,7 @@ template <typename T> ...@@ -80,7 +81,7 @@ template <typename T>
void Buffered<T>::Close() { void Buffered<T>::Close() {
std::unique_lock<std::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
closed_ = true; closed_ = true;
NotifyAllSenders(&lock); NotifyAllParticipants(&lock);
} }
template <typename T> template <typename T>
...@@ -88,7 +89,7 @@ Buffered<T>::~Buffered() { ...@@ -88,7 +89,7 @@ Buffered<T>::~Buffered() {
std::unique_lock<std::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
closed_ = true; closed_ = true;
channel_.clear(); channel_.clear();
NotifyAllSenders(&lock); NotifyAllParticipants(&lock);
} }
template <typename T> template <typename T>
...@@ -97,6 +98,13 @@ void Buffered<T>::NotifyAllSenders(std::unique_lock<std::mutex>* lock) { ...@@ -97,6 +98,13 @@ void Buffered<T>::NotifyAllSenders(std::unique_lock<std::mutex>* lock) {
full_cond_var_.notify_all(); full_cond_var_.notify_all();
} }
template <typename T>
void Buffered<T>::NotifyAllParticipants(std::unique_lock<std::mutex>* lock) {
lock->unlock();
full_cond_var_.notify_all();
empty_cond_var_.notify_all();
}
} // namespace details } // namespace details
} // namespace framework } // namespace framework
} // namespace paddle } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册