diff options
author | Abseil Team <absl-team@google.com> | 2022-05-16 15:25:59 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-05-16 15:26:49 -0700 |
commit | 63607288c14f87999e2b3914dd64e690d75f38f9 (patch) | |
tree | 13cc1b40053cc649d6cd95b4d8c84544fb1f382a /absl | |
parent | 0eb5ac542531d897646caa04a0ceec564772df3c (diff) |
Add a stress test for base_internal::ThreadIdentity reuse.
PiperOrigin-RevId: 449067700
Change-Id: I972b1736c28d76ed500e9ad6fd15c7a469a5825f
Diffstat (limited to 'absl')
-rw-r--r-- | absl/synchronization/internal/per_thread_sem_test.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/absl/synchronization/internal/per_thread_sem_test.cc b/absl/synchronization/internal/per_thread_sem_test.cc index db1184e6..24a6b548 100644 --- a/absl/synchronization/internal/per_thread_sem_test.cc +++ b/absl/synchronization/internal/per_thread_sem_test.cc @@ -174,6 +174,15 @@ TEST_F(PerThreadSemTest, Timeouts) { EXPECT_TRUE(Wait(negative_timeout)); } +TEST_F(PerThreadSemTest, ThreadIdentityReuse) { + // Create a base_internal::ThreadIdentity object and keep reusing it. There + // should be no memory or resource leaks. + for (int i = 0; i < 10000; i++) { + std::thread t([]() { GetOrCreateCurrentThreadIdentity(); }); + t.join(); + } +} + } // namespace } // namespace synchronization_internal |