Public Member Functions | List of all members
rapidsmpf::rrun::ScopedEnvVar Class Reference

RAII guard that saves, optionally modifies, and restores an environment variable. More...

#include <scoped_env_var.hpp>

Public Member Functions

 ScopedEnvVar (char const *name, char const *value)
 Construct the guard, saving and optionally replacing the variable. More...
 
 ScopedEnvVar (ScopedEnvVar const &)=delete
 
ScopedEnvVaroperator= (ScopedEnvVar const &)=delete
 

Detailed Description

RAII guard that saves, optionally modifies, and restores an environment variable.

On construction the current value of the named variable is captured. The caller may pass an initial value to set, or nullptr to unset the variable. On destruction the original state is restored unconditionally, making this class safe to use across code that may throw.

{
ScopedEnvVar guard("CUDA_VISIBLE_DEVICES", nullptr); // unset
// ... topology discovery sees all GPUs ...
} // original CUDA_VISIBLE_DEVICES restored here
ScopedEnvVar(char const *name, char const *value)
Construct the guard, saving and optionally replacing the variable.

Definition at line 29 of file scoped_env_var.hpp.

Constructor & Destructor Documentation

◆ ScopedEnvVar()

rapidsmpf::rrun::ScopedEnvVar::ScopedEnvVar ( char const *  name,
char const *  value 
)
inline

Construct the guard, saving and optionally replacing the variable.

Parameters
nameName of the environment variable.
valueValue to set, or nullptr to unset the variable.

Definition at line 37 of file scoped_env_var.hpp.


The documentation for this class was generated from the following file: