Classes | Functions
gov::fnal::cd::rms::util Namespace Reference

A collection of classes that simplify miscellaneous tasks. More...


class  LinkedBlockingQueue
class  Runnable
class  ThreadWrapper
class  TimeUtils
class  UUIDGenerator


std::string ReentrantGetEnv (const std::string name)

Detailed Description

A collection of classes that simplify miscellaneous tasks.

The util package contains helper classes for managing threads, parsing time and date strings, generating UUIDs as well as thread safe data structures.

Function Documentation

std::string gov::fnal::cd::rms::util::ReentrantGetEnv ( const std::string  name)

getenv() isn't threadsafe, so use a mutex to protect it and copy the output to a string.

nameThe environment variable to retrieve
The value of the requested environment variable if it exists, an empty string otherwise.

Definition at line 22 of file ReentrantGetEnv.cpp.

References cet::getenv(), and generate_CCQE_events::mutex.

Referenced by gov::fnal::cd::rms::provider::RmsConnectionFactory::getConnection(), and gov::fnal::cd::rms::base::RmsDestination::setDefaults().

22  {
23  char *envPtr;
24  static boost::mutex getEnvLock;
26  boost::mutex::scoped_lock lk(getEnvLock);
28  envPtr = getenv(name.c_str());
30  if (envPtr) {
31  return std::string(envPtr);
32  }
33  else {
34  return std::string("");
35  }
36 }
const XML_Char * name
Definition: expat.h:151
std::string getenv(std::string const &name)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154