// Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "absl/synchronization/internal/per_thread_sem.h" #include <atomic> #include <condition_variable> // NOLINT(build/c++11) #include <functional> #include <limits> #include <mutex> // NOLINT(build/c++11) #include <string> #include <thread> // NOLINT(build/c++11) #include "gtest/gtest.h" #include "absl/base/config.h" #include "absl/base/internal/cycleclock.h" #include "absl/base/internal/thread_identity.h" #include "absl/strings/str_cat.h" #include "absl/time/clock.h" #include "absl/time/time.h" // In this test we explicitly avoid the use of synchronization // primitives which might use PerThreadSem, most notably absl::Mutex. namespace absl { ABSL_NAMESPACE_BEGIN namespace synchronization_internal { class SimpleSemaphore { … }; struct ThreadData { … }; // Need friendship with PerThreadSem. class PerThreadSemTest : public testing::Test { … }; namespace { TEST_F(PerThreadSemTest, WithoutTimeout) { … } TEST_F(PerThreadSemTest, WithTimeout) { … } TEST_F(PerThreadSemTest, Timeouts) { … } TEST_F(PerThreadSemTest, ThreadIdentityReuse) { … } } // namespace } // namespace synchronization_internal ABSL_NAMESPACE_END } // namespace absl