uvw
2.10.0
|
Miscellaneous utilities. More...
#include <util.h>
Classes | |
struct | OS |
OS dedicated utilities. More... | |
Static Public Member Functions | |
static int | osPriority (PidType pid) |
Retrieves the scheduling priority of a process. More... | |
static bool | osPriority (PidType pid, int prio) |
Sets the scheduling priority of a process. More... | |
static HandleType | guessHandle (HandleCategory category) noexcept |
Gets the type of the handle given a category. More... | |
static HandleType | guessHandle (FileHandle file) noexcept |
Gets the type of the stream to be used with the given descriptor. More... | |
static std::vector< CPUInfo > | cpuInfo () noexcept |
Gets information about the CPUs on the system. More... | |
static std::vector< InterfaceAddress > | interfaceAddresses () noexcept |
Gets a set of descriptors of all the available interfaces. More... | |
static std::string | indexToName (unsigned int index) noexcept |
IPv6-capable implementation of if_indextoname. More... | |
static std::string | indexToIid (unsigned int index) noexcept |
Retrieves a network interface identifier. More... | |
static bool | replaceAllocator (MallocFuncType mallocFunc, ReallocFuncType reallocFunc, CallocFuncType callocFunc, FreeFuncType freeFunc) noexcept |
Override the use of some standard library’s functions. More... | |
static std::array< double, 3 > | loadAverage () noexcept |
Gets the load average. More... | |
static char ** | setupArgs (int argc, char **argv) |
Store the program arguments. More... | |
static std::string | processTitle () |
Gets the title of the current process. More... | |
static bool | processTitle (const std::string &title) |
Sets the current process title. More... | |
static uint64_t | totalMemory () noexcept |
Gets memory information (in bytes). More... | |
static uint64_t | constrainedMemory () noexcept |
Gets the amount of memory available to the process (in bytes). More... | |
static double | uptime () noexcept |
Gets the current system uptime. More... | |
static RUsage | rusage () noexcept |
Gets the resource usage measures for the current process. More... | |
static uint64_t | hrtime () noexcept |
Gets the current high-resolution real time. More... | |
static std::string | path () noexcept |
Gets the executable path. More... | |
static std::string | cwd () noexcept |
Gets the current working directory. More... | |
static bool | chdir (const std::string &dir) noexcept |
Changes the current working directory. More... | |
static TimeVal64 | timeOfDay () noexcept |
Cross-platform implementation of gettimeofday More... | |
static void | sleep (unsigned int msec) noexcept |
Causes the calling thread to sleep for a while. More... | |
Miscellaneous utilities.
Miscellaneous functions that don’t really belong to any other class.
|
staticnoexcept |
Changes the current working directory.
dir | The working directory to be set. |
|
staticnoexcept |
Gets the amount of memory available to the process (in bytes).
Gets the amount of memory available to the process based on limits imposed by the OS. If there is no such constraint, or the constraint is unknown, 0
is returned.
Note that it is not unusual for this value to be less than or greater than totalMemory
.
|
staticnoexcept |
Gets information about the CPUs on the system.
This function can be used to query the underlying system and get a set of descriptors of all the available CPUs.
|
staticnoexcept |
Gets the current working directory.
|
staticnoexcept |
Gets the type of the stream to be used with the given descriptor.
Returns the type of stream that should be used with a given file descriptor.
Usually this will be used during initialization to guess the type of the stdio streams.
file | A valid descriptor. |
HandleType::UNKNOWN
HandleType::PIPE
HandleType::TCP
HandleType::TTY
HandleType::UDP
HandleType::FILE
|
staticnoexcept |
Gets the type of the handle given a category.
category | A properly initialized handle category. |
|
staticnoexcept |
Gets the current high-resolution real time.
The time is expressed in nanoseconds. It is relative to an arbitrary time in the past. It is not related to the time of the day and therefore not subject to clock drift. The primary use is for measuring performance between interval.
|
staticnoexcept |
Retrieves a network interface identifier.
See the official documentation for further details.
index | Network interface index. |
|
staticnoexcept |
IPv6-capable implementation of if_indextoname.
Mapping between network interface names and indexes.
See the official documentation for further details.
index | Network interface index. |
|
staticnoexcept |
Gets a set of descriptors of all the available interfaces.
This function can be used to query the underlying system and get a set of descriptors of all the available interfaces, either internal or not.
|
staticnoexcept |
Gets the load average.
[0,0,0]
on Windows (not available), the load average otherwise.
|
static |
Retrieves the scheduling priority of a process.
The returned value is between -20 (high priority) and 19 (low priority). A value that is out of range is returned in case of errors.
pid | A valid process id. |
|
static |
Sets the scheduling priority of a process.
The returned value range is between -20 (high priority) and 19 (low priority).
pid | A valid process id. |
prio | The scheduling priority to set to the process. |
|
staticnoexcept |
Gets the executable path.
|
static |
Gets the title of the current process.
|
static |
Sets the current process title.
title | The process title to be set. |
|
staticnoexcept |
Override the use of some standard library’s functions.
Override the use of the standard library’s memory allocation functions.
This method must be invoked before any other uvw
function is called or after all resources have been freed and thus the underlying library doesn’t reference any allocated memory chunk.
If any of the function pointers is null, the invokation will fail.
mallocFunc | Replacement function for malloc. |
reallocFunc | Replacement function for realloc. |
callocFunc | Replacement function for calloc. |
freeFunc | Replacement function for free. |
|
staticnoexcept |
Gets the resource usage measures for the current process.
|
static |
Store the program arguments.
Required for getting / setting the process title.
|
staticnoexcept |
Causes the calling thread to sleep for a while.
msec | Number of milliseconds to sleep. |
|
staticnoexcept |
Cross-platform implementation of gettimeofday
|
staticnoexcept |
Gets memory information (in bytes).
|
staticnoexcept |
Gets the current system uptime.