9 #ifndef CPPCOMMON_THREADS_THREAD_H
10 #define CPPCOMMON_THREADS_THREAD_H
22 #define __THREAD__ CppCommon::Thread::CurrentThreadId()
44 template <
class TOutputStream>
87 template <class Fn, class... Args>
88 static std::thread
Start(Fn&& fn, Args&&... args);
94 static
void Sleep(int64_t milliseconds) noexcept
109 static void Yield() noexcept;
121 static std::bitset<64>
GetAffinity(std::thread& thread);
127 static
void SetAffinity(const std::bitset<64>& affinity);
133 static
void SetAffinity(std::thread& thread, const std::bitset<64>& affinity);
164 #include "thread.inl"
Thread(const Thread &)=delete
static ThreadPriority GetPriority()
Get the current thread priority.
static uint64_t CurrentThreadId() noexcept
Get the current thread Id.
static void Sleep(int64_t milliseconds) noexcept
Sleep the current thread for the given milliseconds.
static void SleepFor(const Timespan ×pan) noexcept
Sleep the current thread for the given timespan.
static void SetPriority(ThreadPriority priority)
Set the current thread priority.
static std::bitset< 64 > GetAffinity()
Get the current thread CPU affinity bitset.
Thread & operator=(const Thread &)=delete
static void Yield() noexcept
Yield to other threads.
static uint32_t CurrentThreadAffinity() noexcept
Get the current thread CPU affinity.
static void SetAffinity(const std::bitset< 64 > &affinity)
Set the current thread CPU affinity bitset.
static void SleepUntil(const UtcTimestamp ×tamp) noexcept
Sleep the current thread until the given timestamp.
static std::thread Start(Fn &&fn, Args &&... args)
Start a new thread with an exception handler registered.
Thread & operator=(Thread &&)=delete
int64_t milliseconds() const noexcept
Get total milliseconds of the current timespan.
Exceptions handler definition.
C++ Common project definitions.
std::ostream & operator<<(std::ostream &os, const uint128_t &value)
ThreadPriority
Thread priorities.
@ NORMAL
Normal thread priority.
@ LOW
Low thread priority.
@ REALTIME
Realtime thread priority.
@ LOWEST
Lowest thread priority.
@ IDLE
Idle thread priority.
@ HIGH
High thread priority.
@ HIGHEST
Highest thread priority.