ADTF  3.18.2
a_util::system Namespace Reference

Serves as component for portable OS (Windows, Linux, ...) functionality. More...

Classes

class  AddressInfo
 Address info class This class can be used to query information about a memory address (e.g. More...
 
class  HighResSchedulingSupport
 RAII class for high resolution scheduling support from the OS. More...
 
class  Timer
 Periodic timer running in a separate thread. More...
 

Functions

std::string getCurrentUserName ()
 Get the current user name. More...
 
std::string getHostname ()
 Get the current hostname. More...
 
a_util::filesystem::Path getExecutablePath ()
 Get full path to the executable that started the calling system process. More...
 
int getLastSystemError ()
 Get the last system error (platform specific, errno or GetLastError) More...
 
void resetLastSystemError ()
 Reset last system error to its initial value.
 
std::string formatSystemError (int system_error_code)
 Get the description message associated with the given system error code. More...
 
void sleepMilliseconds (std::uint32_t ms)
 Yield calling thread to the operating system, scheduled to awake after a period of milliseconds. More...
 
void sleepMicroseconds (std::uint64_t us)
 Yields calling thread to the operating system, scheduled to awake after a period of microseconds. More...
 
timestamp_t getCurrentMilliseconds ()
 Get the current milliseconds passed since system start. More...
 
timestamp_t getCurrentMicroseconds ()
 Get the current microseconds passed since the first invocation (or -1 if not available) More...
 
std::string generateUUIDv4 ()
 Generate a UUIDv4 string. More...
 

Detailed Description

Serves as component for portable OS (Windows, Linux, ...) functionality.

Function Documentation

◆ formatSystemError()

std::string a_util::system::formatSystemError ( int  system_error_code)

Get the description message associated with the given system error code.

Parameters
[in]system_error_codeThe error code to get the description for.
Returns
Description associated with the system error code

◆ generateUUIDv4()

std::string a_util::system::generateUUIDv4 ( )

Generate a UUIDv4 string.

Returns
A fully randomized UUIDv4 string

◆ getCurrentMicroseconds()

timestamp_t a_util::system::getCurrentMicroseconds ( )

Get the current microseconds passed since the first invocation (or -1 if not available)

Note
This method requires high-resolution timer support in the OS
Returns
System running time in microseconds

Referenced by basic_semaphore< Mutex, CondVar >::wait_for().

◆ getCurrentMilliseconds()

timestamp_t a_util::system::getCurrentMilliseconds ( )

Get the current milliseconds passed since system start.

Returns
System running time in milliseconds

◆ getCurrentUserName()

std::string a_util::system::getCurrentUserName ( )

Get the current user name.

Returns
The current name of the user

◆ getExecutablePath()

a_util::filesystem::Path a_util::system::getExecutablePath ( )

Get full path to the executable that started the calling system process.

Returns
Absolute path and including to the executable

◆ getHostname()

std::string a_util::system::getHostname ( )

Get the current hostname.

Returns
The hostname

◆ getLastSystemError()

int a_util::system::getLastSystemError ( )

Get the last system error (platform specific, errno or GetLastError)

Returns
The last system error code

◆ sleepMicroseconds()

void a_util::system::sleepMicroseconds ( std::uint64_t  us)

Yields calling thread to the operating system, scheduled to awake after a period of microseconds.

Note
To achieve the high resolution, use HighResSchedulingSupport
Parameters
[in]usDuration to yield the thread in microseconds

◆ sleepMilliseconds()

void a_util::system::sleepMilliseconds ( std::uint32_t  ms)

Yield calling thread to the operating system, scheduled to awake after a period of milliseconds.

Parameters
[in]msDuration to yield the thread in milliseconds