libzed 1.9.9
A general-purpose library for quick and simple data manipulation.
 
Loading...
Searching...
No Matches
z::system Namespace Reference

This section contains classes and functions relating to system info. More...

Classes

class  cpuid
 A class for easily getting CPU info. More...
 
struct  termsize
 A simple struct for storing terminal width and height. More...
 

Functions

core::generator< bool, bool > interval (double millis) noexcept
 Create a generator that triggers at regular intervals.
 
void sleep (double ms) noexcept
 Delays program execution temporarily.
 
termsize terminal (const std::ostream &stream) noexcept
 Get the current dimensions of the terminal.
 

Detailed Description

This section contains classes and functions relating to system info.

Function Documentation

◆ interval()

core::generator< bool, bool > z::system::interval ( double  millis)
noexcept

Create a generator that triggers at regular intervals.

This generator will yield a dummy value every millis milliseconds. The generator can will run indefinitely by default, but you can limit the number of triggers by using the limit method on the generator.

Parameters
millisThe interval in milliseconds between triggers.
Returns
A generator that yields every millis milliseconds.
Warning
This generator will block the thread for the specified interval, so it should not be used where blocking is not acceptable.
Examples
generator.cpp.

◆ sleep()

void z::system::sleep ( double  ms)
noexcept

Delays program execution temporarily.

This function is meant to be a platform-independent way of allowing the user to put the program to sleep for a little while. Ideally, this could be used to keep the program from taking up too much CPU time when it's not doing anything important.

Parameters
msthe number of milliseconds to wait.
Re-Entry: This function is thread-safe. Simultaneous calls will not cause data races.
Examples
memoize.cpp, and range.cpp.

◆ terminal()

termsize z::system::terminal ( const std::ostream &  stream)
noexcept

Get the current dimensions of the terminal.

Gets the dimensions of the terminal for a specified stream. E.g. std::cout or std::cerr can be passed to get the respective terminal size for each. Any other stream defaults to 80x24.

Parameters
streamThe stream to check terminal size of.
Returns
The width and height of the terminal.