diff options
author | Andrew Morrow <acm@mongodb.com> | 2015-06-19 17:18:25 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2015-06-30 12:16:55 -0400 |
commit | 6abd1d0e9cdc691e6daf30ce3316ffb820b9bb70 (patch) | |
tree | 00b5311c157c3623f92e70234bf4e8cc687c4917 /src/mongo/db | |
parent | 112ab99be08e3217aa87586a697c576dba0de5fd (diff) | |
download | mongo-6abd1d0e9cdc691e6daf30ce3316ffb820b9bb70.tar.gz |
SERVER-19099 Consistently use concurrency and time names via stdx
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/concurrency/lock_state.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/curop_test.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/instance.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/log_process_details.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/range_deleter.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/range_deleter_test.cpp | 46 | ||||
-rw-r--r-- | src/mongo/db/repl/data_replicator.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/repl/data_replicator_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/master_slave.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl_test.cpp | 23 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_executor.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/repl/snapshot_thread.h | 5 | ||||
-rw-r--r-- | src/mongo/db/storage/mmap_v1/dur.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/storage/mmap_v1/file_allocator.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp | 2 |
17 files changed, 56 insertions, 49 deletions
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index 008646a586e..3268e2cbac0 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -226,7 +226,7 @@ void CondVarLockGrantNotification::clear() { LockResult CondVarLockGrantNotification::wait(unsigned timeoutMs) { stdx::unique_lock<stdx::mutex> lock(_mutex); while (_result == LOCK_INVALID) { - if (boost::cv_status::timeout == _cond.wait_for(lock, Milliseconds(timeoutMs))) { + if (stdx::cv_status::timeout == _cond.wait_for(lock, Milliseconds(timeoutMs))) { // Timeout return LOCK_TIMEOUT; } diff --git a/src/mongo/db/curop_test.cpp b/src/mongo/db/curop_test.cpp index 098ead0674f..aaf0933f484 100644 --- a/src/mongo/db/curop_test.cpp +++ b/src/mongo/db/curop_test.cpp @@ -65,6 +65,7 @@ void timeTrackerSetup() { MONGO_INITIALIZER(CurOpTest)(InitializerContext* context) { stdx::thread t(timeTrackerSetup); + t.detach(); // Wait for listener thread to start tracking time. while (Listener::getElapsedTimeMillis() == 0) { diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 257193b53c9..c34daf48d6b 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -1163,6 +1163,7 @@ static void shutdownServer() { /* must do this before unmapping mem or you may get a seg fault */ log(LogComponent::kNetwork) << "shutdown: going to close sockets..." << endl; stdx::thread close_socket_thread(stdx::bind(MessagingPort::closeAllSockets, 0)); + close_socket_thread.detach(); getGlobalServiceContext()->shutdownGlobalStorageEngineCleanly(); } diff --git a/src/mongo/db/log_process_details.cpp b/src/mongo/db/log_process_details.cpp index 9ba6c91299a..777777d7a40 100644 --- a/src/mongo/db/log_process_details.cpp +++ b/src/mongo/db/log_process_details.cpp @@ -44,15 +44,12 @@ namespace mongo { -using std::cout; -using std::endl; - bool is32bit() { return (sizeof(int*) == 4); } void logProcessDetails() { - log() << mongodVersion() << endl; + log() << mongodVersion(); printGitVersion(); printOpenSSLVersion(); printAllocator(); diff --git a/src/mongo/db/range_deleter.cpp b/src/mongo/db/range_deleter.cpp index 036f8e7c4d4..7bb98bbc01f 100644 --- a/src/mongo/db/range_deleter.cpp +++ b/src/mongo/db/range_deleter.cpp @@ -436,7 +436,8 @@ void RangeDeleter::doWork() { { stdx::unique_lock<stdx::mutex> sl(_queueMutex); while (_taskQueue.empty()) { - _taskQueueNotEmptyCV.timed_wait(sl, duration::milliseconds(kNotEmptyTimeoutMillis)); + _taskQueueNotEmptyCV.wait_for(sl, + stdx::chrono::milliseconds(kNotEmptyTimeoutMillis)); if (stopRequested()) { log() << "stopping range deleter worker" << endl; diff --git a/src/mongo/db/range_deleter_test.cpp b/src/mongo/db/range_deleter_test.cpp index 782b7235d60..3db312b7f98 100644 --- a/src/mongo/db/range_deleter_test.cpp +++ b/src/mongo/db/range_deleter_test.cpp @@ -36,8 +36,10 @@ #include "mongo/db/service_context.h" #include "mongo/db/write_concern_options.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/future.h" #include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" +#include "mongo/util/scopeguard.h" namespace { @@ -49,10 +51,11 @@ 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::OperationContext; +using mongo::MakeGuard; namespace stdx = mongo::stdx; @@ -163,13 +166,6 @@ TEST(QueuedDelete, StopWhileWaitingCursor) { ASSERT_FALSE(env->deleteOccured()); } -static void rangeDeleterDeleteNow(RangeDeleter* deleter, - OperationContext* txn, - const RangeDeleterOptions& deleterOptions, - std::string* errMsg) { - deleter->deleteNow(txn, deleterOptions, errMsg); -} - // Should not start delete if the set of cursors that were open when the // deleteNow method is called is still open. TEST(ImmediateDelete, ShouldWaitCursor) { @@ -191,8 +187,16 @@ TEST(ImmediateDelete, ShouldWaitCursor) { RangeDeleterOptions deleterOption( KeyRange(ns, BSON("x" << 0), BSON("x" << 10), BSON("x" << 1))); deleterOption.waitForOpenCursors = true; - stdx::thread deleterThread = stdx::thread( - mongo::stdx::bind(rangeDeleterDeleteNow, &deleter, noTxn, deleterOption, &errMsg)); + + stdx::packaged_task<void()> deleterTask( + [&] { deleter.deleteNow(noTxn, deleterOption, &errMsg); }); + stdx::future<void> deleterFuture = deleterTask.get_future(); + stdx::thread deleterThread(std::move(deleterTask)); + + auto guard = MakeGuard([&] { + deleter.stopWorkers(); + deleterThread.join(); + }); env->waitForNthGetCursor(1u); @@ -206,8 +210,8 @@ TEST(ImmediateDelete, ShouldWaitCursor) { env->addCursorId(ns, 200); env->removeCursorId(ns, 345); - ASSERT_TRUE( - deleterThread.timed_join(boost::posix_time::seconds(MAX_IMMEDIATE_DELETE_WAIT_SECS))); + ASSERT_TRUE(stdx::future_status::ready == + deleterFuture.wait_for(stdx::chrono::seconds(MAX_IMMEDIATE_DELETE_WAIT_SECS))); ASSERT_TRUE(env->deleteOccured()); const DeletedRange deletedChunk(env->getLastDelete()); @@ -216,8 +220,6 @@ TEST(ImmediateDelete, ShouldWaitCursor) { ASSERT_TRUE(deletedChunk.min.equal(BSON("x" << 0))); ASSERT_TRUE(deletedChunk.max.equal(BSON("x" << 10))); ASSERT_TRUE(deletedChunk.shardKeyPattern.equal(BSON("x" << 1))); - - deleter.stopWorkers(); } // Should terminate when stop is requested. @@ -240,8 +242,14 @@ TEST(ImmediateDelete, StopWhileWaitingCursor) { RangeDeleterOptions deleterOption( KeyRange(ns, BSON("x" << 0), BSON("x" << 10), BSON("x" << 1))); deleterOption.waitForOpenCursors = true; - stdx::thread deleterThread = stdx::thread( - mongo::stdx::bind(rangeDeleterDeleteNow, &deleter, noTxn, deleterOption, &errMsg)); + + stdx::packaged_task<void()> deleterTask( + [&] { deleter.deleteNow(noTxn, deleterOption, &errMsg); }); + stdx::future<void> deleterFuture = deleterTask.get_future(); + stdx::thread deleterThread(std::move(deleterTask)); + + auto join_thread_guard = MakeGuard([&] { deleterThread.join(); }); + auto stop_deleter_guard = MakeGuard([&] { deleter.stopWorkers(); }); env->waitForNthGetCursor(1u); @@ -251,10 +259,10 @@ TEST(ImmediateDelete, StopWhileWaitingCursor) { ASSERT_FALSE(env->deleteOccured()); - deleter.stopWorkers(); + stop_deleter_guard.Execute(); - ASSERT_TRUE( - deleterThread.timed_join(boost::posix_time::seconds(MAX_IMMEDIATE_DELETE_WAIT_SECS))); + ASSERT_TRUE(stdx::future_status::ready == + deleterFuture.wait_for(stdx::chrono::seconds(MAX_IMMEDIATE_DELETE_WAIT_SECS))); ASSERT_FALSE(env->deleteOccured()); } diff --git a/src/mongo/db/repl/data_replicator.cpp b/src/mongo/db/repl/data_replicator.cpp index 11c55208268..feb2ec711b2 100644 --- a/src/mongo/db/repl/data_replicator.cpp +++ b/src/mongo/db/repl/data_replicator.cpp @@ -33,7 +33,6 @@ #include "data_replicator.h" #include <algorithm> -#include <thread> #include "mongo/base/status.h" #include "mongo/client/query_fetcher.h" diff --git a/src/mongo/db/repl/data_replicator_test.cpp b/src/mongo/db/repl/data_replicator_test.cpp index 84cd64c1866..661c97d6e57 100644 --- a/src/mongo/db/repl/data_replicator_test.cpp +++ b/src/mongo/db/repl/data_replicator_test.cpp @@ -356,7 +356,7 @@ protected: } void verifySync(Status s = Status::OK()) { - verifySync(_isbr->getResult().getStatus().code()); + ASSERT_EQ(_isbr->getResult().getStatus(), s) << "status objects differ"; } void verifySync(ErrorCodes::Error code) { diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp index 074a7fcbe77..7a9eea27a98 100644 --- a/src/mongo/db/repl/master_slave.cpp +++ b/src/mongo/db/repl/master_slave.cpp @@ -1348,12 +1348,14 @@ void startMasterSlave(OperationContext* txn) { verify(replSettings.slave == SimpleSlave); LOG(1) << "slave=true" << endl; stdx::thread repl_thread(replSlaveThread); + repl_thread.detach(); } if (replSettings.master) { LOG(1) << "master=true" << endl; createOplog(txn); stdx::thread t(replMasterThread); + t.detach(); } if (replSettings.fastsync) { diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 213cb9f38a6..1f7334e5481 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -824,7 +824,7 @@ void waitUpToOneSecondForTimestampChange(const Timestamp& referenceTime) { stdx::unique_lock<stdx::mutex> lk(newOpMutex); while (referenceTime == getLastSetTimestamp()) { - if (!newTimestampNotifier.timed_wait(lk, boost::posix_time::seconds(1))) + if (stdx::cv_status::timeout == newTimestampNotifier.wait_for(lk, stdx::chrono::seconds(1))) return; } } diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp index de1e0eb1e05..0f811630297 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp @@ -30,7 +30,6 @@ #include "mongo/platform/basic.h" -#include <future> #include <iostream> #include <memory> #include <set> @@ -57,6 +56,7 @@ #include "mongo/db/write_concern_options.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/future.h" #include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" @@ -1872,7 +1872,6 @@ TEST_F(ReplCoordTest, AwaitReplicationReconfigNodeCountExceedsNumberOfNodes) { getNet()->exitNetwork(); reconfigThread.join(); ASSERT_OK(status); - std::cout << "asdf" << std::endl; // writeconcern feasability should be reevaluated and an error should be returned ReplicationCoordinator::StatusAndDuration statusAndDur = awaiter.getResult(); @@ -2162,11 +2161,11 @@ TEST_F(ReplCoordTest, ReadAfterDeferredGreaterOpTime) { getReplCoord()->setMyLastOptime(OpTimeWithTermZero(0, 0)); - auto pseudoLogOp = std::async(std::launch::async, - [this]() { - // Not guaranteed to be scheduled after waitUnitl blocks... - getReplCoord()->setMyLastOptime(OpTimeWithTermZero(200, 0)); - }); + auto pseudoLogOp = stdx::async(stdx::launch::async, + [this]() { + // Not guaranteed to be scheduled after waitUntil blocks... + getReplCoord()->setMyLastOptime(OpTimeWithTermZero(200, 0)); + }); auto result = getReplCoord()->waitUntilOpTime(&txn, ReadAfterOpTimeArgs(OpTimeWithTermZero(100, 0))); @@ -2189,11 +2188,11 @@ TEST_F(ReplCoordTest, ReadAfterDeferredEqualOpTime) { OpTimeWithTermZero opTimeToWait(100, 0); - auto pseudoLogOp = std::async(std::launch::async, - [this, &opTimeToWait]() { - // Not guaranteed to be scheduled after waitUnitl blocks... - getReplCoord()->setMyLastOptime(opTimeToWait); - }); + auto pseudoLogOp = stdx::async(stdx::launch::async, + [this, &opTimeToWait]() { + // Not guaranteed to be scheduled after waitUntil blocks... + getReplCoord()->setMyLastOptime(opTimeToWait); + }); auto result = getReplCoord()->waitUntilOpTime(&txn, ReadAfterOpTimeArgs(opTimeToWait)); pseudoLogOp.get(); diff --git a/src/mongo/db/repl/replication_executor.cpp b/src/mongo/db/repl/replication_executor.cpp index 30c0b0ef733..0c366836bb2 100644 --- a/src/mongo/db/repl/replication_executor.cpp +++ b/src/mongo/db/repl/replication_executor.cpp @@ -33,7 +33,6 @@ #include "mongo/db/repl/replication_executor.h" #include <limits> -#include <thread> #include "mongo/db/repl/database_task.h" #include "mongo/db/repl/storage_interface.h" diff --git a/src/mongo/db/repl/snapshot_thread.h b/src/mongo/db/repl/snapshot_thread.h index 71aeede08d8..c657ee0d554 100644 --- a/src/mongo/db/repl/snapshot_thread.h +++ b/src/mongo/db/repl/snapshot_thread.h @@ -28,11 +28,10 @@ #pragma once -#include <functional> - #include "mongo/base/disallow_copying.h" #include "mongo/db/service_context.h" #include "mongo/db/storage/snapshot_manager.h" +#include "mongo/stdx/functional.h" #include "mongo/stdx/thread.h" namespace mongo { @@ -48,7 +47,7 @@ class SnapshotThread { MONGO_DISALLOW_COPYING(SnapshotThread); public: - using Callback = std::function<void(SnapshotName)>; + using Callback = stdx::function<void(SnapshotName)>; /** * Starts a thread to take periodic snapshots if supported by the storageEngine. diff --git a/src/mongo/db/storage/mmap_v1/dur.cpp b/src/mongo/db/storage/mmap_v1/dur.cpp index a17a7a80d51..359e231f1b3 100644 --- a/src/mongo/db/storage/mmap_v1/dur.cpp +++ b/src/mongo/db/storage/mmap_v1/dur.cpp @@ -687,7 +687,7 @@ static void durThread() { stdx::unique_lock<stdx::mutex> lock(flushMutex); for (unsigned i = 0; i <= 2; i++) { - if (boost::cv_status::no_timeout == + if (stdx::cv_status::no_timeout == flushRequested.wait_for(lock, Milliseconds(oneThird))) { // Someone forced a flush break; diff --git a/src/mongo/db/storage/mmap_v1/file_allocator.cpp b/src/mongo/db/storage/mmap_v1/file_allocator.cpp index f033e1c6a5a..04fa0e6f420 100644 --- a/src/mongo/db/storage/mmap_v1/file_allocator.cpp +++ b/src/mongo/db/storage/mmap_v1/file_allocator.cpp @@ -129,6 +129,7 @@ FileAllocator::FileAllocator() : _failed() {} void FileAllocator::start() { stdx::thread t(stdx::bind(&FileAllocator::run, this)); + t.detach(); } void FileAllocator::requestAllocation(const string& name, long& size) { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index 536eb8c2ac3..8611347b206 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -620,7 +620,7 @@ int64_t WiredTigerRecordStore::cappedDeleteAsNeeded(OperationContext* txn, // Don't wait forever: we're in a transaction, we could block eviction. if (!lock.try_lock()) { Date_t before = Date_t::now(); - (void)lock.timed_lock(boost::posix_time::millisec(200)); + (void)lock.try_lock_for(stdx::chrono::milliseconds(200)); stdx::chrono::milliseconds delay = Date_t::now() - before; _cappedSleep.fetchAndAdd(1); _cappedSleepMS.fetchAndAdd(delay.count()); @@ -635,7 +635,7 @@ int64_t WiredTigerRecordStore::cappedDeleteAsNeeded(OperationContext* txn, // Don't wait forever: we're in a transaction, we could block eviction. Date_t before = Date_t::now(); - bool gotLock = lock.timed_lock(boost::posix_time::millisec(200)); + bool gotLock = lock.try_lock_for(stdx::chrono::milliseconds(200)); stdx::chrono::milliseconds delay = Date_t::now() - before; _cappedSleep.fetchAndAdd(1); _cappedSleepMS.fetchAndAdd(delay.count()); @@ -823,7 +823,7 @@ bool WiredTigerRecordStore::isCappedHidden(const RecordId& loc) const { } RecordId WiredTigerRecordStore::lowestCappedHiddenRecord() const { - boost::lock_guard<boost::mutex> lk(_uncommittedDiskLocsMutex); + stdx::lock_guard<stdx::mutex> lk(_uncommittedDiskLocsMutex); return _uncommittedDiskLocs.empty() ? RecordId() : _uncommittedDiskLocs.front(); } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index 1d45be06a97..d08e6c6fbc9 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -62,7 +62,7 @@ struct WaitUntilDurableData { stdx::unique_lock<stdx::mutex> lk(mutex); long long start = lastSyncTime; numWaitingForSync.fetchAndAdd(1); - condvar.timed_wait(lk, boost::posix_time::milliseconds(50)); + condvar.wait_for(lk, stdx::chrono::milliseconds(50)); numWaitingForSync.fetchAndAdd(-1); return lastSyncTime > start; } |