utility¶
- group turbo_base
Functions
- TURBO_FORCE_INLINE void assume (bool cond)
This function is used to make assumptions about the condition.
It uses different compiler intrinsics based on the compiler being used.
The
assume_unreachablefunction is used to indicate to the compiler that a certain code path is unreachable. This function uses different compiler intrinsics based on the compiler being used. It is used when the condition is always false. This can be useful for optimization purposes, as it allows the compiler to make assumptions about the code that can potentially lead to more efficient code generation.- Parameters:
cond – The condition that is assumed to be true.
- TURBO_FORCE_INLINE void assume_unreachable ()
This function is used to make assumptions about the condition.
It uses different compiler intrinsics based on the compiler being used.
See also
assume(bool cond), this function is used when the condition is always false.
- TURBO_DLL int pid () noexcept
Get the current process id.
- Returns:
The current process id
- TURBO_DLL bool is_color_terminal () noexcept
Determine if the terminal supports colors Source: https://github.com/agauniyal/rang/.
- Returns:
- TURBO_DLL bool in_terminal (std::FILE *file) noexcept
Determine if the terminal attached Source: https://github.com/agauniyal/rang/.
See also
- Parameters:
file – The file to check
- Returns:
True if the terminal is attached, false otherwise
- TURBO_DLL size_t thread_id () noexcept
Get the current thread id, this is thread local, so it is unique per thread.
different from std::this_thread::get_id(). actually it is act as gettid() in linux.
- Returns:
The current thread id
-
uint64_t thread_numeric_id()¶
Get the current thread id, on linux same as pthread_self().
-
inline double nominal_cpu_frequency()¶
Get the nominal cpu frequency of the current machine.
Nominal core processor cycles per second of each processor. This is not necessarily the frequency of the CycleClock counter Thread-safe.
- Returns:
-
inline size_t cpu_num()¶
Get the number of logical processors (hyperthreads) in system.
Thread-safe.
- Returns: