StormByte-System 2.0.0
C++26 process and environment module of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::System::ThisThread Namespace Reference

Calling-thread helpers (the current thread, not a child process). More...

Enumerations

enum class  Error { Success = 0 , TooLong , Failed }
 ThisThread enumerators. More...
 

Functions

StormByte::Error::Fault LastError () noexcept
 Last ThisThread error on this thread.
 
template<typename Rep , typename Period >
void Sleep (const std::chrono::duration< Rep, Period > &duration)
 Suspend the calling thread.
 
bool Name (std::string_view name)
 Set the calling thread name.
 
bool Name (StormByte::String::String &name)
 Read the calling thread name.
 

Detailed Description

Calling-thread helpers (the current thread, not a child process).

Sleep does not touch LastError. Every other call returns true on success and updates LastError for this thread. An output String is valid only when the call returned true.

Enumeration Type Documentation

◆ Error

ThisThread enumerators.

Domain tag StormByte.System.ThisThread. Zero is success.

Enumerator
Success 

No error.

TooLong 

The name exceeds the platform limit.

Failed 

The platform call failed.

Function Documentation

◆ LastError()

StormByte::Error::Fault StormByte::System::ThisThread::LastError ( )
noexcept

Last ThisThread error on this thread.

Returns
Success or an Error code. Stored in the System module TLS.

◆ Name() [1/2]

bool StormByte::System::ThisThread::Name ( std::string_view  name)

Set the calling thread name.

Parameters
nameProposed name. Not truncated.
Returns
true if the name was set.

◆ Name() [2/2]

bool StormByte::System::ThisThread::Name ( StormByte::String::String &  name)

Read the calling thread name.

Parameters
[out]nameOwned UTF-8 text. Written only on success.
Returns
true if a name was read.

◆ Sleep()

template<typename Rep , typename Period >
void StormByte::System::ThisThread::Sleep ( const std::chrono::duration< Rep, Period > &  duration)
inline

Suspend the calling thread.

Template Parameters
RepDuration representation.
PeriodDuration period.
Parameters
durationSleep interval.