From 62c1133f42055211db82a2e075768fb438f8c0c4 Mon Sep 17 00:00:00 2001 From: yuyang18 Date: Mon, 9 Jul 2018 11:26:10 +0800 Subject: [PATCH] Add mutex for decorated_chain --- paddle/fluid/framework/reader.cc | 1 + paddle/fluid/framework/reader.h | 1 + 2 files changed, 2 insertions(+) diff --git a/paddle/fluid/framework/reader.cc b/paddle/fluid/framework/reader.cc index e1d2ac79cf0..9884e941219 100644 --- a/paddle/fluid/framework/reader.cc +++ b/paddle/fluid/framework/reader.cc @@ -21,6 +21,7 @@ ReaderBase::~ReaderBase() {} void ReaderBase::InsertDecoratedReader( const std::shared_ptr &decorated_reader) { + std::lock_guard guard(decorated_readers_mtx_); decorated_readers_.emplace_back(decorated_reader); } diff --git a/paddle/fluid/framework/reader.h b/paddle/fluid/framework/reader.h index 730e3faace1..01ef349300f 100644 --- a/paddle/fluid/framework/reader.h +++ b/paddle/fluid/framework/reader.h @@ -45,6 +45,7 @@ class ReaderBase { const std::shared_ptr& decorated_reader); // A set of which readers that decorated this reader. std::vector> decorated_readers_; + std::mutex decorated_readers_mtx_; }; class DecoratedReader : public ReaderBase, -- GitLab