diff options
author | 2015-08-27 07:46:20 -0700 | |
---|---|---|
committer | 2015-08-27 07:46:20 -0700 | |
commit | 70a816807f215f134a69b07daf89914ed7b13def (patch) | |
tree | 66cf3647878b4b7fa71bb6727111c7524867dd99 /test/cpp/end2end/streaming_throughput_test.cc | |
parent | a0461e52f3b90afa6054f48a32a654a9c7d28f6f (diff) |
Friends dont let friends use volatile for synchronization
Diffstat (limited to 'test/cpp/end2end/streaming_throughput_test.cc')
-rw-r--r-- | test/cpp/end2end/streaming_throughput_test.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/cpp/end2end/streaming_throughput_test.cc b/test/cpp/end2end/streaming_throughput_test.cc index 48f273b29e..7ecd782b10 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<EchoResponse, EchoRequest>* stream) GRPC_OVERRIDE { EchoRequest request; - volatile bool should_exit = false; + std::atomic<bool> 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; } |