diff options
author | Andy Schwerin <schwerin@10gen.com> | 2013-05-23 13:43:28 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@10gen.com> | 2013-06-03 18:53:52 -0400 |
commit | 9b148b0419d79f7173d0e972e8427fea67f77616 (patch) | |
tree | bc9c96a4a82c4384a7d5220b69417eb1835b922c /src/mongo/platform | |
parent | 06c6c3b6fb835e1bcc62e5f725aca6d815cfb42e (diff) | |
download | mongo-9b148b0419d79f7173d0e972e8427fea67f77616.tar.gz |
SERVER-9809 Replace getpid() with ProcessId::getCurrent() and pid_t with ProcessId.
Diffstat (limited to 'src/mongo/platform')
-rw-r--r-- | src/mongo/platform/process_id.cpp | 9 | ||||
-rw-r--r-- | src/mongo/platform/process_id.h | 6 | ||||
-rw-r--r-- | src/mongo/platform/process_id_test.cpp | 2 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/mongo/platform/process_id.cpp b/src/mongo/platform/process_id.cpp index ef5a6ecc80b..424933ada0d 100644 --- a/src/mongo/platform/process_id.cpp +++ b/src/mongo/platform/process_id.cpp @@ -19,6 +19,7 @@ #include <boost/static_assert.hpp> #include <iostream> +#include <sstream> #include <limits> namespace mongo { @@ -49,8 +50,14 @@ namespace mongo { return static_cast<long long>(asInt64()); } + std::string ProcessId::toString() const { + std::ostringstream os; + os << *this; + return os.str(); + } + std::ostream& operator<<(std::ostream& os, ProcessId pid) { - return os << pid.asInt64(); + return os << pid.toNative(); } } // namespace mongo diff --git a/src/mongo/platform/process_id.h b/src/mongo/platform/process_id.h index 208b921a1c0..1f067307667 100644 --- a/src/mongo/platform/process_id.h +++ b/src/mongo/platform/process_id.h @@ -16,6 +16,7 @@ #pragma once #include <iosfwd> +#include <string> #ifndef _WIN32 #include <unistd.h> @@ -80,6 +81,11 @@ namespace mongo { */ uint32_t asUInt32() const { return static_cast<uint32_t>(_npid); } + /** + * Provides a string representation of the pid. + */ + std::string toString() const; + bool operator==(const ProcessId other) const { return _npid == other._npid; } bool operator!=(const ProcessId other) const { return _npid != other._npid; } bool operator<(const ProcessId other) const { return _npid < other._npid; } diff --git a/src/mongo/platform/process_id_test.cpp b/src/mongo/platform/process_id_test.cpp index 83053e3d886..60d2844c16e 100644 --- a/src/mongo/platform/process_id_test.cpp +++ b/src/mongo/platform/process_id_test.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "mongo/platform/basic.h" + #include "mongo/platform/process_id.h" #include "mongo/unittest/unittest.h" |