Warning, /include/absl/base/internal/spinlock_win32.inc is written in an unsupported language. File is not indexed.
0001 // Copyright 2017 The Abseil Authors.
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 // https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 //
0015 // This file is a Win32-specific part of spinlock_wait.cc
0016
0017 #include <windows.h>
0018 #include <atomic>
0019 #include "absl/base/internal/scheduling_mode.h"
0020
0021 extern "C" {
0022
0023 void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockDelay)(
0024 std::atomic<uint32_t>* /* lock_word */, uint32_t /* value */, int loop,
0025 absl::base_internal::SchedulingMode /* mode */) {
0026 if (loop == 0) {
0027 } else if (loop == 1) {
0028 Sleep(0);
0029 } else {
0030 // SpinLockSuggestedDelayNS() always returns a positive integer, so this
0031 // static_cast is safe.
0032 Sleep(static_cast<DWORD>(
0033 absl::base_internal::SpinLockSuggestedDelayNS(loop) / 1000000));
0034 }
0035 }
0036
0037 void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockWake)(
0038 std::atomic<uint32_t>* /* lock_word */, bool /* all */) {}
0039
0040 } // extern "C"