diff options
Diffstat (limited to 'abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc')
-rw-r--r-- | abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc b/abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc index 8cf59e6..24a6b54 100644 --- a/abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc +++ b/abseil-cpp/absl/synchronization/internal/per_thread_sem_test.cc @@ -159,7 +159,7 @@ TEST_F(PerThreadSemTest, Timeouts) { const absl::Duration elapsed = absl::Now() - start; // Allow for a slight early return, to account for quality of implementation // issues on various platforms. - const absl::Duration slop = absl::Microseconds(200); + const absl::Duration slop = absl::Milliseconds(1); EXPECT_LE(delay - slop, elapsed) << "Wait returned " << delay - elapsed << " early (with " << slop << " slop), start time was " << start; @@ -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 |