aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/cc/training
diff options
context:
space:
mode:
authorGravatar Yuefeng Zhou <yuefengz@google.com>2016-10-24 10:35:59 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-10-24 11:51:39 -0700
commitf502125a5e4957b0f1adfa1a2524131d0e183fd6 (patch)
tree3741e052318f54be13c8c93e1af457f22d35a36b /tensorflow/cc/training
parentc944d1a96e1fbc48d689381cf93e91946087ee01 (diff)
Make the boolean should_stop_ atomic.
Change: 137059071
Diffstat (limited to 'tensorflow/cc/training')
-rw-r--r--tensorflow/cc/training/queue_runner.cc2
-rw-r--r--tensorflow/cc/training/queue_runner.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/tensorflow/cc/training/queue_runner.cc b/tensorflow/cc/training/queue_runner.cc
index 81f49c5dcf..585ee15872 100644
--- a/tensorflow/cc/training/queue_runner.cc
+++ b/tensorflow/cc/training/queue_runner.cc
@@ -80,7 +80,7 @@ Status QueueRunner::Join() {
void QueueRunner::Run(Session* sess, const string& enqueue_op) {
bool decremented = false;
- while (!should_stop_) {
+ while (!should_stop_.load()) {
std::vector<Tensor> outputs;
auto status = sess->Run({}, {}, {enqueue_op}, &outputs);
if (status.ok()) {
diff --git a/tensorflow/cc/training/queue_runner.h b/tensorflow/cc/training/queue_runner.h
index 7eeab8bd45..09d8d49821 100644
--- a/tensorflow/cc/training/queue_runner.h
+++ b/tensorflow/cc/training/queue_runner.h
@@ -66,7 +66,7 @@ class QueueRunner {
std::unordered_set<int> queue_closed_exception_types_;
std::unique_ptr<thread::ThreadPool> thread_pool_;
- bool should_stop_;
+ std::atomic<bool> should_stop_;
std::atomic<bool> started_;
mutex mu_;
// TODO(yuefengz): implement c++ coordinator.