From 70a816807f215f134a69b07daf89914ed7b13def Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 27 Aug 2015 07:46:20 -0700 Subject: [PATCH] Friends dont let friends use volatile for synchronization --- test/cpp/end2end/streaming_throughput_test.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cpp/end2end/streaming_throughput_test.cc b/test/cpp/end2end/streaming_throughput_test.cc index 48f273b29e2..7ecd782b101 100644 --- a/test/cpp/end2end/streaming_throughput_test.cc +++ b/test/cpp/end2end/streaming_throughput_test.cc @@ -104,11 +104,11 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { ServerReaderWriter* stream) GRPC_OVERRIDE { EchoRequest request; - volatile bool should_exit = false; + std::atomic should_exit(false); std::thread sender([stream, &should_exit]() { EchoResponse response; response.set_message(kLargeString); - while (!should_exit) { + while (!should_exit.load()) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); stream->Write(response); } @@ -117,7 +117,7 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { while (stream->Read(&request)) { std::this_thread::sleep_for(std::chrono::milliseconds(3)); } - should_exit = true; + should_exit.store(true); sender.join(); return Status::OK; }