Merge pull request #4365 from tanzislam:fix-thread-count-after-thread-creation

PiperOrigin-RevId: 564472305
Change-Id: I8db9bc0ba0768e7ab9c67f36d9db87edbbf14f10
This commit is contained in:
Copybara-Service 2023-09-11 12:46:26 -07:00
commit eab0e7e289

View File

@ -296,7 +296,7 @@ void* ThreadFunc(void* data) {
TEST(GetThreadCountTest, ReturnsCorrectValue) { TEST(GetThreadCountTest, ReturnsCorrectValue) {
size_t starting_count; size_t starting_count;
size_t thread_count_after_create; size_t thread_count_after_create;
size_t thread_count_after_join; size_t thread_count_after_join = 0;
// We can't guarantee that no other thread was created or destroyed between // We can't guarantee that no other thread was created or destroyed between
// any two calls to GetThreadCount(). We make multiple attempts, hoping that // any two calls to GetThreadCount(). We make multiple attempts, hoping that
@ -316,9 +316,9 @@ TEST(GetThreadCountTest, ReturnsCorrectValue) {
const int status = pthread_create(&thread_id, &attr, &ThreadFunc, &mutex); const int status = pthread_create(&thread_id, &attr, &ThreadFunc, &mutex);
ASSERT_EQ(0, pthread_attr_destroy(&attr)); ASSERT_EQ(0, pthread_attr_destroy(&attr));
ASSERT_EQ(0, status); ASSERT_EQ(0, status);
}
thread_count_after_create = GetThreadCount(); thread_count_after_create = GetThreadCount();
}
void* dummy; void* dummy;
ASSERT_EQ(0, pthread_join(thread_id, &dummy)); ASSERT_EQ(0, pthread_join(thread_id, &dummy));