12#if !ALIB_SINGLE_THREADED
31#if ALIB_SINGLE_THREADED
96 virtual void Run() =0;
101#if !ALIB_SINGLE_THREADED
124 #if !DOXYGEN && !ALIB_SINGLE_THREADED
131 #if !ALIB_SINGLE_THREADED
179 :
Thread( nullptr, pName ) {}
267 virtual void Start();
281 #if ( !defined(_MSC_VER) && !defined( ALIB_API_NO_DLL ) ) || DOXYGEN
342 { std::this_thread::sleep_for( std::chrono::milliseconds( milliseconds ) ); }
350 { std::this_thread::sleep_for( std::chrono::microseconds( microseconds ) ); }
357 { std::this_thread::sleep_for( std::chrono::nanoseconds( nanoseconds ) ); }
362 static void Sleep (
const Ticks::Duration& duration )
363 { std::this_thread::sleep_for( duration.Export() ); }
368 static void Sleep (
const Ticks::Duration::TDuration& duration )
369 { std::this_thread::sleep_for( duration ); }
376 { std::this_thread::sleep_until(
time.Export() ); }
381#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 void SetName(const character *newName)
virtual void Run() override
std::thread * c11Thread
The internal C++ thread object.
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 Thread * GetMain()
static Thread * Get(std::thread::id nativeID)
Details of namespace #"alib::threads;2".
void threadStart(Thread *thread)
void BootstrapThreadMap(integer qty)
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.
integer ThreadID
The ALib thread identifier type.
threads::ThreadID ThreadID
Type to store thread identifiers.
threads::Thread Thread
Type alias in namespace #"%alib".
void Bootstrap(BootstrapPhases targetPhase, camp::Camp *targetCamp, int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
lang::integer integer
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".