12#if !ALIB_SINGLE_THREADED
31#if ALIB_SINGLE_THREADED
97 virtual void Run() = 0;
102#if !ALIB_SINGLE_THREADED
126 #if !DOXYGEN && !ALIB_SINGLE_THREADED
133 #if !ALIB_SINGLE_THREADED
182 :
Thread( nullptr, pName ) {}
273 virtual void Start();
287 #if ( !defined(_MSC_VER) && !defined( ALIB_API_NO_DLL ) ) || DOXYGEN
347 { std::this_thread::sleep_for( std::chrono::milliseconds( milliseconds ) ); }
354 { std::this_thread::sleep_for( std::chrono::microseconds( microseconds ) ); }
360 { std::this_thread::sleep_for( std::chrono::nanoseconds( nanoseconds ) ); }
365 static void Sleep (
const Ticks::Duration& duration )
366 { std::this_thread::sleep_for( duration.Export() ); }
371 static void Sleep (
const Ticks::Duration::TDuration& duration )
372 { std::this_thread::sleep_for( duration ); }
378 { std::this_thread::sleep_until(
time.Export() ); }
383#if !ALIB_SINGLE_THREADED
virtual ~Runnable()
Virtual destructor.
@ Running
The thread's Run method is currently processed.
@ Started
Method Start was invoked but not running, yet.
@ Terminated
The thread is terminated.
static Thread * GetCurrent()
std::thread::id nativeID
The internal C++ thread id.
const character * name
The name of the thread.
static void SleepMillis(int milliseconds)
static void Sleep(const Ticks::Duration::TDuration &duration)
static void SleepNanos(int64_t nanoseconds)
static void Sleep(const Ticks::Duration &duration)
static void YieldToSystem()
static void SleepMicros(int64_t microseconds)
virtual ~Thread() override
Thread(const character *pName=A_CHAR(""))
virtual ALIB_DLL void Start()
virtual void SetName(const character *newName)
virtual void Run() override
std::thread * c11Thread
The internal C++ thread object.
virtual ALIB_DLL void Join()
State state
Internal flag to indicate if the thread is alive.
Runnable * runnable
The runnable to execute.
ThreadID id
The id of the thread.
Thread(const Thread &)=delete
Deleted copy constructor.
static void SleepUntil(const Ticks &time)
virtual const character * GetName() const
std::thread::id GetNativeID() const
static ALIB_DLL Thread * GetMain()
static ALIB_DLL Thread * Get(std::thread::id nativeID)
Details of namespace alib::threads.
void threadStart(Thread *thread)
void BootstrapThreadMap(integer qty)
integer ThreadID
The ALib thread identifier type.
thread_local Thread * THIS_THREAD
A thread-local pointer to the ALib representation of the actual thread.
constexpr ThreadID UNDEFINED
This is a value that may be passed as a value indicating an undefined thread.
threads::ThreadID ThreadID
Type to store thread identifiers.
lang::integer integer
Type alias in namespace alib.
void Bootstrap(BootstrapPhases targetPhase, camp::Camp *targetCamp, int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
threads::Thread Thread
Type alias in namespace alib.
threads::Runnable Runnable
Type alias in namespace alib.
time::Ticks Ticks
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.