diff options
Diffstat (limited to 'src/mongo/db/background.cpp')
-rw-r--r-- | src/mongo/db/background.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/mongo/db/background.cpp b/src/mongo/db/background.cpp index 0f7b9cd7eea..62afb3e099b 100644 --- a/src/mongo/db/background.cpp +++ b/src/mongo/db/background.cpp @@ -35,8 +35,8 @@ #include <string> #include "mongo/db/operation_context.h" -#include "mongo/stdx/condition_variable.h" -#include "mongo/stdx/mutex.h" +#include "mongo/platform/condition_variable.h" +#include "mongo/platform/mutex.h" #include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/map_util.h" @@ -56,13 +56,13 @@ public: void recordBegin(); int recordEnd(); - void awaitNoBgOps(stdx::unique_lock<stdx::mutex>& lk); + void awaitNoBgOps(stdx::unique_lock<Latch>& lk); int getOpsInProgCount() const { return _opsInProgCount; } - void waitForAnOpRemoval(stdx::unique_lock<stdx::mutex>& lk, OperationContext* opCtx); + void waitForAnOpRemoval(stdx::unique_lock<Latch>& lk, OperationContext* opCtx); private: int _opsInProgCount; @@ -75,7 +75,7 @@ typedef StringMap<std::shared_ptr<BgInfo>> BgInfoMap; typedef BgInfoMap::const_iterator BgInfoMapIterator; // Static data for this file is never destroyed. -stdx::mutex& m = *(new stdx::mutex()); +Mutex& m = *(new Mutex()); BgInfoMap& dbsInProg = *(new BgInfoMap()); BgInfoMap& nsInProg = *(new BgInfoMap()); @@ -94,12 +94,12 @@ int BgInfo::recordEnd() { return _opsInProgCount; } -void BgInfo::awaitNoBgOps(stdx::unique_lock<stdx::mutex>& lk) { +void BgInfo::awaitNoBgOps(stdx::unique_lock<Latch>& lk) { while (_opsInProgCount > 0) _noOpsInProg.wait(lk); } -void BgInfo::waitForAnOpRemoval(stdx::unique_lock<stdx::mutex>& lk, OperationContext* opCtx) { +void BgInfo::waitForAnOpRemoval(stdx::unique_lock<Latch>& lk, OperationContext* opCtx) { int startOpRemovalsCount = _opRemovalsCount; // Wait for an index build to finish. @@ -122,7 +122,7 @@ void recordEndAndRemove(BgInfoMap& bgiMap, StringData key) { } } -void awaitNoBgOps(stdx::unique_lock<stdx::mutex>& lk, BgInfoMap* bgiMap, StringData key) { +void awaitNoBgOps(stdx::unique_lock<Latch>& lk, BgInfoMap* bgiMap, StringData key) { std::shared_ptr<BgInfo> bgInfo = mapFindWithDefault(*bgiMap, key, std::shared_ptr<BgInfo>()); if (!bgInfo) return; @@ -132,7 +132,7 @@ void awaitNoBgOps(stdx::unique_lock<stdx::mutex>& lk, BgInfoMap* bgiMap, StringD } // namespace void BackgroundOperation::waitUntilAnIndexBuildFinishes(OperationContext* opCtx, StringData ns) { - stdx::unique_lock<stdx::mutex> lk(m); + stdx::unique_lock<Latch> lk(m); std::shared_ptr<BgInfo> bgInfo = mapFindWithDefault(nsInProg, ns, std::shared_ptr<BgInfo>()); if (!bgInfo) { // There are no index builds in progress on the collection, so no need to wait. @@ -142,12 +142,12 @@ void BackgroundOperation::waitUntilAnIndexBuildFinishes(OperationContext* opCtx, } bool BackgroundOperation::inProgForDb(StringData db) { - stdx::lock_guard<stdx::mutex> lk(m); + stdx::lock_guard<Latch> lk(m); return dbsInProg.find(db) != dbsInProg.end(); } int BackgroundOperation::numInProgForDb(StringData db) { - stdx::lock_guard<stdx::mutex> lk(m); + stdx::lock_guard<Latch> lk(m); std::shared_ptr<BgInfo> bgInfo = mapFindWithDefault(dbsInProg, db, std::shared_ptr<BgInfo>()); if (!bgInfo) return 0; @@ -155,7 +155,7 @@ int BackgroundOperation::numInProgForDb(StringData db) { } bool BackgroundOperation::inProgForNs(StringData ns) { - stdx::lock_guard<stdx::mutex> lk(m); + stdx::lock_guard<Latch> lk(m); return nsInProg.find(ns) != nsInProg.end(); } @@ -189,29 +189,29 @@ void BackgroundOperation::assertNoBgOpInProgForNs(StringData ns) { } void BackgroundOperation::awaitNoBgOpInProgForDb(StringData db) { - stdx::unique_lock<stdx::mutex> lk(m); + stdx::unique_lock<Latch> lk(m); awaitNoBgOps(lk, &dbsInProg, db); } void BackgroundOperation::awaitNoBgOpInProgForNs(StringData ns) { - stdx::unique_lock<stdx::mutex> lk(m); + stdx::unique_lock<Latch> lk(m); awaitNoBgOps(lk, &nsInProg, ns); } BackgroundOperation::BackgroundOperation(StringData ns) : _ns(ns) { - stdx::lock_guard<stdx::mutex> lk(m); + stdx::lock_guard<Latch> lk(m); recordBeginAndInsert(dbsInProg, _ns.db()); recordBeginAndInsert(nsInProg, _ns.ns()); } BackgroundOperation::~BackgroundOperation() { - stdx::lock_guard<stdx::mutex> lk(m); + stdx::lock_guard<Latch> lk(m); recordEndAndRemove(dbsInProg, _ns.db()); recordEndAndRemove(nsInProg, _ns.ns()); } void BackgroundOperation::dump(std::ostream& ss) { - stdx::lock_guard<stdx::mutex> lk(m); + stdx::lock_guard<Latch> lk(m); if (nsInProg.size()) { ss << "\n<b>Background Jobs in Progress</b>\n"; for (BgInfoMapIterator i = nsInProg.begin(); i != nsInProg.end(); ++i) |