ddn.util.monaco.safe

Types 3

Process information structure for @nogc environments.

This struct uses fixed-size buffers instead of dynamic arrays to avoid garbage collector allocations. It's suitable for real-time systems and environments where GC pauses are unacceptable.

Example:

auto info = processInfoNoGC(getpid());
import std.string : fromStringz;
writeln("Process: ", fromStringz(info.name.ptr));

Fields
int pid
char[256] name
int parentPid
ulong memoryBytes
double cpuPercent
Methods
void initialize() @nogc nothrow @safeInitializes the struct with default values.

Buffer for storing process IDs without GC allocation.

This struct provides a fixed-size buffer for storing process IDs, suitable for @nogc environments.

Example:

auto buffer = pidsNoGC();
writeln("Found ", buffer.count, " processes");
for (size_t i = 0; i < buffer.count; i++) {
  writeln("PID: ", buffer.pids[i]);
}

Fields
int[4096] pids
size_t count
Methods
void initialize() @nogc nothrow @safeInitializes the buffer.

Pre-allocated buffer for storing process information.

This struct provides a fixed-size buffer for storing process information without requiring garbage collector allocation. Suitable for real-time systems and high-frequency monitoring.

Example:

ProcessBuffer buffer;
fillProcessBuffer(buffer);
writeln("Found ", buffer.count, " processes");

Fields
ProcessInfoNoGC[1024] processes
size_t count
Methods
void initialize() @nogc nothrow @safeInitializes the buffer.

Functions 5

fnbool pidExistsNoGC(int pid) @nogc nothrow @safeChecks if a process exists without GC allocation.
fnPidsBuffer pidsNoGC() @nogc @safeGets all process IDs without GC allocation.
private fnvoid readCommFile(const char * path, ref char[256] nameBuffer) @nogc @trusted nothrowReads process name from /proc/<pid>/comm file.
fnProcessInfoNoGC processInfoNoGC(int pid) @nogc @safeGets process information without GC allocation.
fnvoid fillProcessBuffer(ref ProcessBuffer buffer) @nogc @safeFills a pre-allocated buffer with process information.