diff options
author | Andrew Morrow <acm@mongodb.com> | 2015-06-30 12:18:27 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2015-07-06 18:34:06 -0400 |
commit | 896c568ab136c9735482a59abcab499bda997565 (patch) | |
tree | a7fff3d50906cff75d2bc1f44e4a698658768994 | |
parent | 6e7683cb836aa08b6df9aa2738774015236cd126 (diff) | |
download | mongo-896c568ab136c9735482a59abcab499bda997565.tar.gz |
SERVER-19099 Use std:: to back stdx polyfills
-rw-r--r-- | src/mongo/db/range_deleter_test.cpp | 34 | ||||
-rw-r--r-- | src/mongo/logger/console.cpp | 2 | ||||
-rw-r--r-- | src/mongo/stdx/chrono.h | 4 | ||||
-rw-r--r-- | src/mongo/stdx/condition_variable.h | 8 | ||||
-rw-r--r-- | src/mongo/stdx/future.h | 14 | ||||
-rw-r--r-- | src/mongo/stdx/mutex.h | 20 | ||||
-rw-r--r-- | src/mongo/stdx/thread.h | 6 | ||||
-rw-r--r-- | src/mongo/util/ntservice.cpp | 6 |
8 files changed, 45 insertions, 49 deletions
diff --git a/src/mongo/db/range_deleter_test.cpp b/src/mongo/db/range_deleter_test.cpp index 3db312b7f98..29034535e44 100644 --- a/src/mongo/db/range_deleter_test.cpp +++ b/src/mongo/db/range_deleter_test.cpp @@ -41,24 +41,11 @@ #include "mongo/unittest/unittest.h" #include "mongo/util/scopeguard.h" +namespace mongo { namespace { using std::string; -using mongo::BSONObj; -using mongo::CursorId; -using mongo::DeletedRange; -using mongo::FieldParser; -using mongo::KeyRange; -using mongo::Notification; -using mongo::OperationContext; -using mongo::RangeDeleter; -using mongo::RangeDeleterMockEnv; -using mongo::RangeDeleterOptions; -using mongo::MakeGuard; - -namespace stdx = mongo::stdx; - OperationContext* const noTxn = NULL; // MockEnv doesn't need txn XXX SERVER-13931 // Capped sleep interval is 640 mSec, Nyquist frequency is 1280 mSec => round up to 2 sec. @@ -188,9 +175,12 @@ TEST(ImmediateDelete, ShouldWaitCursor) { KeyRange(ns, BSON("x" << 0), BSON("x" << 10), BSON("x" << 1))); deleterOption.waitForOpenCursors = true; - stdx::packaged_task<void()> deleterTask( - [&] { deleter.deleteNow(noTxn, deleterOption, &errMsg); }); - stdx::future<void> deleterFuture = deleterTask.get_future(); + // VS2013 Doesn't support future<void>, so fake it with a bool. + stdx::packaged_task<bool()> deleterTask([&] { + deleter.deleteNow(noTxn, deleterOption, &errMsg); + return true; + }); + stdx::future<bool> deleterFuture = deleterTask.get_future(); stdx::thread deleterThread(std::move(deleterTask)); auto guard = MakeGuard([&] { @@ -243,9 +233,12 @@ TEST(ImmediateDelete, StopWhileWaitingCursor) { KeyRange(ns, BSON("x" << 0), BSON("x" << 10), BSON("x" << 1))); deleterOption.waitForOpenCursors = true; - stdx::packaged_task<void()> deleterTask( - [&] { deleter.deleteNow(noTxn, deleterOption, &errMsg); }); - stdx::future<void> deleterFuture = deleterTask.get_future(); + // VS2013 Doesn't support future<void>, so fake it with a bool. + stdx::packaged_task<bool()> deleterTask([&] { + deleter.deleteNow(noTxn, deleterOption, &errMsg); + return true; + }); + stdx::future<bool> deleterFuture = deleterTask.get_future(); stdx::thread deleterThread(std::move(deleterTask)); auto join_thread_guard = MakeGuard([&] { deleterThread.join(); }); @@ -370,3 +363,4 @@ TEST(MixedDeletes, MultipleDeletes) { } } // unnamed namespace +} // namespace mongo diff --git a/src/mongo/logger/console.cpp b/src/mongo/logger/console.cpp index 90945ad7f21..d2f4cdc6ac8 100644 --- a/src/mongo/logger/console.cpp +++ b/src/mongo/logger/console.cpp @@ -228,6 +228,8 @@ std::ostream* windowsOutputStream = getWindowsOutputStream(); } // namespace Console::Console() : _consoleLock() { + const std::ios_base::Init initializeCout; + if (consoleMutex) { stdx::unique_lock<stdx::mutex> lk(*consoleMutex); lk.swap(_consoleLock); diff --git a/src/mongo/stdx/chrono.h b/src/mongo/stdx/chrono.h index 47ab2a2d231..39d49cd876c 100644 --- a/src/mongo/stdx/chrono.h +++ b/src/mongo/stdx/chrono.h @@ -28,12 +28,12 @@ #pragma once -#include <boost/chrono.hpp> +#include <chrono> namespace mongo { namespace stdx { -namespace chrono = boost::chrono; // NOLINT +namespace chrono = ::std::chrono; // NOLINT } // namespace stdx } // namespace mongo diff --git a/src/mongo/stdx/condition_variable.h b/src/mongo/stdx/condition_variable.h index 206a9e84465..d2dcd0a9a57 100644 --- a/src/mongo/stdx/condition_variable.h +++ b/src/mongo/stdx/condition_variable.h @@ -28,14 +28,14 @@ #pragma once -#include <boost/thread/condition_variable.hpp> +#include <condition_variable> namespace mongo { namespace stdx { -using condition_variable = boost::condition_variable; // NOLINT -using condition_variable_any = boost::condition_variable_any; // NOLINT -using cv_status = boost::cv_status; // NOLINT +using condition_variable = ::std::condition_variable; // NOLINT +using condition_variable_any = ::std::condition_variable_any; // NOLINT +using cv_status = ::std::cv_status; // NOLINT } // namespace stdx } // namespace mongo diff --git a/src/mongo/stdx/future.h b/src/mongo/stdx/future.h index bc4816aff6f..c16b3c5996b 100644 --- a/src/mongo/stdx/future.h +++ b/src/mongo/stdx/future.h @@ -28,17 +28,17 @@ #pragma once -#include <boost/thread/future.hpp> +#include <future> namespace mongo { namespace stdx { -using boost::async; // NOLINT -using boost::future; // NOLINT -using boost::future_status; // NOLINT -using boost::launch; // NOLINT -using boost::packaged_task; // NOLINT -using boost::promise; // NOLINT +using ::std::async; // NOLINT +using ::std::future; // NOLINT +using ::std::future_status; // NOLINT +using ::std::launch; // NOLINT +using ::std::packaged_task; // NOLINT +using ::std::promise; // NOLINT } // namespace stdx } // namespace mongo diff --git a/src/mongo/stdx/mutex.h b/src/mongo/stdx/mutex.h index 4303d25fba2..51c7318c639 100644 --- a/src/mongo/stdx/mutex.h +++ b/src/mongo/stdx/mutex.h @@ -28,23 +28,21 @@ #pragma once -#include <boost/thread/locks.hpp> -#include <boost/thread/mutex.hpp> -#include <boost/thread/recursive_mutex.hpp> +#include <mutex> namespace mongo { namespace stdx { -using boost::mutex; // NOLINT -using boost::timed_mutex; // NOLINT -using boost::recursive_mutex; // NOLINT +using ::std::mutex; // NOLINT +using ::std::timed_mutex; // NOLINT +using ::std::recursive_mutex; // NOLINT -using boost::adopt_lock_t; // NOLINT -using boost::defer_lock_t; // NOLINT -using boost::try_to_lock_t; // NOLINT +using ::std::adopt_lock_t; // NOLINT +using ::std::defer_lock_t; // NOLINT +using ::std::try_to_lock_t; // NOLINT -using boost::lock_guard; // NOLINT -using boost::unique_lock; // NOLINT +using ::std::lock_guard; // NOLINT +using ::std::unique_lock; // NOLINT #if _MSC_VER < 1900 #define MONGO_STDX_CONSTEXPR const diff --git a/src/mongo/stdx/thread.h b/src/mongo/stdx/thread.h index e46900c02a3..2c88ba31119 100644 --- a/src/mongo/stdx/thread.h +++ b/src/mongo/stdx/thread.h @@ -28,13 +28,13 @@ #pragma once -#include <boost/thread.hpp> +#include <thread> namespace mongo { namespace stdx { -using thread = boost::thread; // NOLINT -namespace this_thread = boost::this_thread; // NOLINT +using thread = ::std::thread; // NOLINT +namespace this_thread = ::std::this_thread; // NOLINT } // namespace stdx } // namespace mongo diff --git a/src/mongo/util/ntservice.cpp b/src/mongo/util/ntservice.cpp index b70835d1ab6..18a44334b40 100644 --- a/src/mongo/util/ntservice.cpp +++ b/src/mongo/util/ntservice.cpp @@ -513,14 +513,16 @@ const int kStopWaitHintMillis = 30000; // On client OSes, SERVICE_CONTROL_SHUTDOWN has a 5 second timeout configured in // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control static void serviceStop() { - stdx::packaged_task<void()> exitCleanlyTask([] { + // VS2013 Doesn't support future<void>, so fake it with a bool. + stdx::packaged_task<bool()> exitCleanlyTask([] { Client::initThread("serviceStopWorker"); // Stop the process // TODO: SERVER-5703, separate the "cleanup for shutdown" functionality from // the "terminate process" functionality in exitCleanly. exitCleanly(EXIT_WINDOWS_SERVICE_STOP); + return true; }); - stdx::future<void> exitedCleanly = exitCleanlyTask.get_future(); + stdx::future<bool> exitedCleanly = exitCleanlyTask.get_future(); // Launch the packaged task in a thread. We needn't ever join it, // so it doesn't even need a name. |