|
|
|||
File indexing completed on 2025-12-16 09:41:07
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 // ----------------------------------------------------------------------------- 0016 // File: clock.h 0017 // ----------------------------------------------------------------------------- 0018 // 0019 // This header file contains utility functions for working with the system-wide 0020 // realtime clock. For descriptions of the main time abstractions used within 0021 // this header file, consult the time.h header file. 0022 #ifndef ABSL_TIME_CLOCK_H_ 0023 #define ABSL_TIME_CLOCK_H_ 0024 0025 #include <cstdint> 0026 0027 #include "absl/base/config.h" 0028 #include "absl/base/macros.h" 0029 #include "absl/time/time.h" 0030 0031 namespace absl { 0032 ABSL_NAMESPACE_BEGIN 0033 0034 // Now() 0035 // 0036 // Returns the current time, expressed as an `absl::Time` absolute time value. 0037 absl::Time Now(); 0038 0039 // GetCurrentTimeNanos() 0040 // 0041 // Returns the current time, expressed as a count of nanoseconds since the Unix 0042 // Epoch (https://en.wikipedia.org/wiki/Unix_time). Prefer `absl::Now()` instead 0043 // for all but the most performance-sensitive cases (i.e. when you are calling 0044 // this function hundreds of thousands of times per second). 0045 int64_t GetCurrentTimeNanos(); 0046 0047 // SleepFor() 0048 // 0049 // Sleeps for the specified duration, expressed as an `absl::Duration`. 0050 // 0051 // Notes: 0052 // * Signal interruptions will not reduce the sleep duration. 0053 // * Returns immediately when passed a nonpositive duration. 0054 void SleepFor(absl::Duration duration); 0055 0056 ABSL_NAMESPACE_END 0057 } // namespace absl 0058 0059 // ----------------------------------------------------------------------------- 0060 // Implementation Details 0061 // ----------------------------------------------------------------------------- 0062 0063 // In some build configurations we pass --detect-odr-violations to the 0064 // gold linker. This causes it to flag weak symbol overrides as ODR 0065 // violations. Because ODR only applies to C++ and not C, 0066 // --detect-odr-violations ignores symbols not mangled with C++ names. 0067 // By changing our extension points to be extern "C", we dodge this 0068 // check. 0069 extern "C" { 0070 ABSL_DLL void ABSL_INTERNAL_C_SYMBOL(AbslInternalSleepFor)( 0071 absl::Duration duration); 0072 } // extern "C" 0073 0074 inline void absl::SleepFor(absl::Duration duration) { 0075 ABSL_INTERNAL_C_SYMBOL(AbslInternalSleepFor)(duration); 0076 } 0077 0078 #endif // ABSL_TIME_CLOCK_H_
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|