diff options
author | Ben Becker <benjamin.becker@10gen.com> | 2012-02-29 16:36:35 -0800 |
---|---|---|
committer | Ben Becker <benjamin.becker@10gen.com> | 2012-02-29 16:36:35 -0800 |
commit | 215735b2a6c9bfc6b22102b83e4efc24e2be02a7 (patch) | |
tree | 3444dc682903975cc0b3880fe9653e2d20f0c45e /src/mongo | |
parent | 9fcca4f886ce7176178a3168ebd9c67422ad951e (diff) | |
download | mongo-215735b2a6c9bfc6b22102b83e4efc24e2be02a7.tar.gz |
SERVER-5147: replace static init with init upon construction
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/util/processinfo.cpp | 4 | ||||
-rw-r--r-- | src/mongo/util/processinfo.h | 25 | ||||
-rwxr-xr-x | src/mongo/util/processinfo_win32.cpp | 2 |
3 files changed, 14 insertions, 17 deletions
diff --git a/src/mongo/util/processinfo.cpp b/src/mongo/util/processinfo.cpp index 13b4f006a2a..17b31de6430 100644 --- a/src/mongo/util/processinfo.cpp +++ b/src/mongo/util/processinfo.cpp @@ -47,8 +47,4 @@ namespace mongo { pidFileWiper.write( path ); } -#if !defined(_WIN32) - // static system data - ProcessInfo::SystemInfo ProcessInfo::_sysInfo; -#endif } diff --git a/src/mongo/util/processinfo.h b/src/mongo/util/processinfo.h index 432b6803810..1a7cbd80f56 100644 --- a/src/mongo/util/processinfo.h +++ b/src/mongo/util/processinfo.h @@ -49,48 +49,48 @@ namespace mongo { /** * Get the type of os (e.g. Windows, Linux, Mac OS) */ - const string& getOsType() const { return _sysInfo.osType; } + const string& getOsType() const { return sysInfo().osType; } /** * Get the os Name (e.g. Ubuntu, Gentoo, Windows Server 2008) */ - const string& getOsName() const { return _sysInfo.osName; } + const string& getOsName() const { return sysInfo().osName; } /** * Get the os version (e.g. 10.04, 11.3.0, 6.1 (build 7600)) */ - const string& getOsVersion() const { return _sysInfo.osVersion; } + const string& getOsVersion() const { return sysInfo().osVersion; } /** * Get the cpu address size (e.g. 32, 36, 64) */ - const unsigned getAddrSize() const { return _sysInfo.addrSize; } + const unsigned getAddrSize() const { return sysInfo().addrSize; } /** * Get the total amount of system memory in MB */ - const unsigned long long getMemSizeMB() const { return _sysInfo.memSize / (1024 * 1024); } + const unsigned long long getMemSizeMB() const { return sysInfo().memSize / (1024 * 1024); } /** * Get the number of CPUs */ - const unsigned getNumCores() const { return _sysInfo.numCores; } + const unsigned getNumCores() const { return sysInfo().numCores; } /** * Get the CPU architecture (e.g. x86, x86_64) */ - const string& getArch() const { return _sysInfo.cpuArch; } + const string& getArch() const { return sysInfo().cpuArch; } /** * Determine if NUMA is enabled (interleaved) for this process */ - bool hasNumaEnabled() const { return _sysInfo.hasNuma; } + bool hasNumaEnabled() const { return sysInfo().hasNuma; } /** * Get extra system stats */ void appendSystemDetails( BSONObjBuilder& details ) const { - details.append( StringData("extra"), _sysInfo._extraStats.copy() ); + details.append( StringData("extra"), sysInfo()._extraStats.copy() ); } /** @@ -133,9 +133,12 @@ namespace mongo { }; pid_t _pid; - static SystemInfo _sysInfo; - static bool checkNumaEnabled(); + const SystemInfo& sysInfo() const { + // initialize and collect sysInfo on first call + static ProcessInfo::SystemInfo *initSysInfo = new SystemInfo(); + return *initSysInfo; + } }; diff --git a/src/mongo/util/processinfo_win32.cpp b/src/mongo/util/processinfo_win32.cpp index e699ec89a5e..88e61b74851 100755 --- a/src/mongo/util/processinfo_win32.cpp +++ b/src/mongo/util/processinfo_win32.cpp @@ -222,6 +222,4 @@ namespace mongo { return false; } - // Static symbols - ProcessInfo::SystemInfo ProcessInfo::_sysInfo; } |