8#ifndef HPP_ALIB_THREADS_THREAD
9#define HPP_ALIB_THREADS_THREAD 1
11#ifndef HPP_ALIB_STRINGS_ASTRING
15#if !defined (_GLIBCXX_THREAD) && !defined (_THREAD_ )
23# if !defined(HPP_ALIB_TIME_TICKS)
29# if !defined(HPP_ALIB_ENUMS_RECORDS)
33namespace alib {
namespace threads {
95 virtual void Run() = 0;
112 #if !defined(ALIB_DOX)
171 :
Thread( nullptr, pName )
267 virtual void Start();
311 std::this_thread::yield();
324 std::this_thread::sleep_for( std::chrono::milliseconds( milliseconds ) );
338 std::this_thread::sleep_for( std::chrono::microseconds( microseconds ) );
351 std::this_thread::sleep_for( std::chrono::nanoseconds( nanoseconds ) );
363 void Sleep (
const Ticks::Duration& duration )
365 std::this_thread::sleep_for( duration.Export() );
378 std::this_thread::sleep_until( time.
Export() );
398#if ALIB_ENUMS && ALIB_BOXING
static ALIB_API void YieldToSystem()
virtual ALIB_API void Start()
static Thread * GetCurrent()
virtual void SetName(const String &newName)
static void SleepUntil(const Ticks &time)
virtual ALIB_API ~Thread() override
@ Running
The thread's Run method is currently processed.
@ Started
Method Start was invoked but not running, yet.
@ Terminated
The thread is terminated.
virtual const CString GetName()
static void SleepNanos(int64_t nanoseconds)
static ALIB_API Thread * GetMain()
virtual ALIB_API void Terminate()
ALIB_API Thread(const String &pName=EmptyString())
virtual void Run() override
static void SleepMicros(int64_t microseconds)
static void SleepMillis(int milliseconds)
static void Sleep(const Ticks::Duration &duration)
TTimePoint Export() const
#define ALIB_ASSERT_MODULE(modulename)
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
void threadStart(Thread *thread)
ALIB_API Thread * getThread(std::thread::id c11ID)
static constexpr ThreadID UNDEFINED
threads::Thread Thread
Type alias in namespace alib.
constexpr CString EmptyString()
lang::integer integer
Type alias in namespace alib.
threads::ThreadID ThreadID
Type to store thread identifiers.