// 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. // The OS-specific header included below must provide two calls: // AbslInternalSpinLockDelay() and AbslInternalSpinLockWake(). // See spinlock_wait.h for the specs. #include <atomic> #include <cstdint> #include "absl/base/internal/spinlock_wait.h" #if defined(_WIN32) #include "absl/base/internal/spinlock_win32.inc" #elif defined(__linux__) #include "absl/base/internal/spinlock_linux.inc" #elif defined(__akaros__) #include "absl/base/internal/spinlock_akaros.inc" #else #include "absl/base/internal/spinlock_posix.inc" #endif namespace absl { ABSL_NAMESPACE_BEGIN namespace base_internal { // See spinlock_wait.h for spec. uint32_t SpinLockWait(std::atomic<uint32_t> *w, int n, const SpinLockWaitTransition trans[], base_internal::SchedulingMode scheduling_mode) { … } static std::atomic<uint64_t> delay_rand; // Return a suggested delay in nanoseconds for iteration number "loop" int SpinLockSuggestedDelayNS(int loop) { … } } // namespace base_internal ABSL_NAMESPACE_END } // namespace absl