diff --git a/test/cpp/end2end/message_allocator_end2end_test.cc b/test/cpp/end2end/message_allocator_end2end_test.cc index b34a08ef281..c15066794bc 100644 --- a/test/cpp/end2end/message_allocator_end2end_test.cc +++ b/test/cpp/end2end/message_allocator_end2end_test.cc @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -235,8 +236,8 @@ class SimpleAllocatorTest : public MessageAllocatorEnd2endTestBase { class MessageHolderImpl : public experimental::MessageHolder { public: - MessageHolderImpl(int* request_deallocation_count, - int* messages_deallocation_count) + MessageHolderImpl(std::atomic_int* request_deallocation_count, + std::atomic_int* messages_deallocation_count) : request_deallocation_count_(request_deallocation_count), messages_deallocation_count_(messages_deallocation_count) { set_request(new EchoRequest); @@ -261,8 +262,8 @@ class SimpleAllocatorTest : public MessageAllocatorEnd2endTestBase { } private: - int* request_deallocation_count_; - int* messages_deallocation_count_; + std::atomic_int* const request_deallocation_count_; + std::atomic_int* const messages_deallocation_count_; }; experimental::MessageHolder* AllocateMessages() override { @@ -271,8 +272,8 @@ class SimpleAllocatorTest : public MessageAllocatorEnd2endTestBase { &messages_deallocation_count); } int allocation_count = 0; - int request_deallocation_count = 0; - int messages_deallocation_count = 0; + std::atomic_int request_deallocation_count{0}; + std::atomic_int messages_deallocation_count{0}; }; };