summaryrefslogtreecommitdiff
path: root/src/mongo/db/range_deleter_mock_env.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/range_deleter_mock_env.cpp
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/range_deleter_mock_env.cpp')
-rw-r--r--src/mongo/db/range_deleter_mock_env.cpp178
1 files changed, 86 insertions, 92 deletions
diff --git a/src/mongo/db/range_deleter_mock_env.cpp b/src/mongo/db/range_deleter_mock_env.cpp
index f831c746ceb..1ee01d6a19a 100644
--- a/src/mongo/db/range_deleter_mock_env.cpp
+++ b/src/mongo/db/range_deleter_mock_env.cpp
@@ -34,125 +34,119 @@
namespace mongo {
- using std::set;
- using std::string;
+using std::set;
+using std::string;
- bool DeletedRangeCmp::operator()(const DeletedRange& lhs,
- const DeletedRange& rhs) const {
- const int nsComp = lhs.ns.compare(rhs.ns);
+bool DeletedRangeCmp::operator()(const DeletedRange& lhs, const DeletedRange& rhs) const {
+ const int nsComp = lhs.ns.compare(rhs.ns);
- if (nsComp < 0) {
- return true;
- }
-
- if (nsComp > 0) {
- return false;
- }
-
- return compareRanges(lhs.min, lhs.max, rhs.min, rhs.max) < 0;
+ if (nsComp < 0) {
+ return true;
}
- RangeDeleterMockEnv::RangeDeleterMockEnv():
- _pauseDelete(false),
- _pausedCount(0),
- _getCursorsCallCount(0) {
-
- setGlobalServiceContext(stdx::make_unique<ServiceContextNoop>());
+ if (nsComp > 0) {
+ return false;
}
- void RangeDeleterMockEnv::addCursorId(StringData ns, CursorId id) {
- stdx::lock_guard<stdx::mutex> sl(_cursorMapMutex);
- _cursorMap[ns.toString()].insert(id);
- }
+ return compareRanges(lhs.min, lhs.max, rhs.min, rhs.max) < 0;
+}
- void RangeDeleterMockEnv::removeCursorId(StringData ns, CursorId id) {
- stdx::lock_guard<stdx::mutex> sl(_cursorMapMutex);
- _cursorMap[ns.toString()].erase(id);
- }
+RangeDeleterMockEnv::RangeDeleterMockEnv()
+ : _pauseDelete(false), _pausedCount(0), _getCursorsCallCount(0) {
+ setGlobalServiceContext(stdx::make_unique<ServiceContextNoop>());
+}
- void RangeDeleterMockEnv::pauseDeletes() {
- stdx::lock_guard<stdx::mutex> sl(_pauseDeleteMutex);
- _pauseDelete = true;
- }
+void RangeDeleterMockEnv::addCursorId(StringData ns, CursorId id) {
+ stdx::lock_guard<stdx::mutex> sl(_cursorMapMutex);
+ _cursorMap[ns.toString()].insert(id);
+}
- void RangeDeleterMockEnv::resumeOneDelete() {
- stdx::lock_guard<stdx::mutex> sl(_pauseDeleteMutex);
- _pauseDelete = false;
- _pausedCV.notify_one();
- }
+void RangeDeleterMockEnv::removeCursorId(StringData ns, CursorId id) {
+ stdx::lock_guard<stdx::mutex> sl(_cursorMapMutex);
+ _cursorMap[ns.toString()].erase(id);
+}
- void RangeDeleterMockEnv::waitForNthGetCursor(uint64_t nthCall) {
- stdx::unique_lock<stdx::mutex> sl(_envStatMutex);
- while (_getCursorsCallCount < nthCall) {
- _cursorsCallCountUpdatedCV.wait(sl);
- }
- }
+void RangeDeleterMockEnv::pauseDeletes() {
+ stdx::lock_guard<stdx::mutex> sl(_pauseDeleteMutex);
+ _pauseDelete = true;
+}
- void RangeDeleterMockEnv::waitForNthPausedDelete(uint64_t nthPause) {
- stdx::unique_lock<stdx::mutex> sl(_pauseDeleteMutex);
- while(_pausedCount < nthPause) {
- _pausedDeleteChangeCV.wait(sl);
- }
- }
+void RangeDeleterMockEnv::resumeOneDelete() {
+ stdx::lock_guard<stdx::mutex> sl(_pauseDeleteMutex);
+ _pauseDelete = false;
+ _pausedCV.notify_one();
+}
- bool RangeDeleterMockEnv::deleteOccured() const {
- stdx::lock_guard<stdx::mutex> sl(_deleteListMutex);
- return !_deleteList.empty();
+void RangeDeleterMockEnv::waitForNthGetCursor(uint64_t nthCall) {
+ stdx::unique_lock<stdx::mutex> sl(_envStatMutex);
+ while (_getCursorsCallCount < nthCall) {
+ _cursorsCallCountUpdatedCV.wait(sl);
}
+}
- DeletedRange RangeDeleterMockEnv::getLastDelete() const {
- stdx::lock_guard<stdx::mutex> sl(_deleteListMutex);
- return _deleteList.back();
+void RangeDeleterMockEnv::waitForNthPausedDelete(uint64_t nthPause) {
+ stdx::unique_lock<stdx::mutex> sl(_pauseDeleteMutex);
+ while (_pausedCount < nthPause) {
+ _pausedDeleteChangeCV.wait(sl);
}
+}
- bool RangeDeleterMockEnv::deleteRange(OperationContext* txn,
- const RangeDeleteEntry& taskDetails,
- long long int* deletedDocs,
- string* errMsg) {
+bool RangeDeleterMockEnv::deleteOccured() const {
+ stdx::lock_guard<stdx::mutex> sl(_deleteListMutex);
+ return !_deleteList.empty();
+}
- {
- stdx::unique_lock<stdx::mutex> sl(_pauseDeleteMutex);
- bool wasInitiallyPaused = _pauseDelete;
+DeletedRange RangeDeleterMockEnv::getLastDelete() const {
+ stdx::lock_guard<stdx::mutex> sl(_deleteListMutex);
+ return _deleteList.back();
+}
- if (_pauseDelete) {
- _pausedCount++;
- _pausedDeleteChangeCV.notify_one();
- }
+bool RangeDeleterMockEnv::deleteRange(OperationContext* txn,
+ const RangeDeleteEntry& taskDetails,
+ long long int* deletedDocs,
+ string* errMsg) {
+ {
+ stdx::unique_lock<stdx::mutex> sl(_pauseDeleteMutex);
+ bool wasInitiallyPaused = _pauseDelete;
- while (_pauseDelete) {
- _pausedCV.wait(sl);
- }
+ if (_pauseDelete) {
+ _pausedCount++;
+ _pausedDeleteChangeCV.notify_one();
+ }
- _pauseDelete = wasInitiallyPaused;
+ while (_pauseDelete) {
+ _pausedCV.wait(sl);
}
- {
- stdx::lock_guard<stdx::mutex> sl(_deleteListMutex);
+ _pauseDelete = wasInitiallyPaused;
+ }
- DeletedRange entry;
- entry.ns = taskDetails.options.range.ns;
- entry.min = taskDetails.options.range.minKey.getOwned();
- entry.max = taskDetails.options.range.maxKey.getOwned();
- entry.shardKeyPattern = taskDetails.options.range.keyPattern.getOwned();
+ {
+ stdx::lock_guard<stdx::mutex> sl(_deleteListMutex);
- _deleteList.push_back(entry);
- }
+ DeletedRange entry;
+ entry.ns = taskDetails.options.range.ns;
+ entry.min = taskDetails.options.range.minKey.getOwned();
+ entry.max = taskDetails.options.range.maxKey.getOwned();
+ entry.shardKeyPattern = taskDetails.options.range.keyPattern.getOwned();
- return true;
+ _deleteList.push_back(entry);
}
- void RangeDeleterMockEnv::getCursorIds(
- OperationContext* txn, StringData ns, set<CursorId>* in) {
- {
- stdx::lock_guard<stdx::mutex> sl(_cursorMapMutex);
- const set<CursorId>& _cursors = _cursorMap[ns.toString()];
- std::copy(_cursors.begin(), _cursors.end(), inserter(*in, in->begin()));
- }
+ return true;
+}
- {
- stdx::lock_guard<stdx::mutex> sl(_envStatMutex);
- _getCursorsCallCount++;
- _cursorsCallCountUpdatedCV.notify_one();
- }
+void RangeDeleterMockEnv::getCursorIds(OperationContext* txn, StringData ns, set<CursorId>* in) {
+ {
+ stdx::lock_guard<stdx::mutex> sl(_cursorMapMutex);
+ const set<CursorId>& _cursors = _cursorMap[ns.toString()];
+ std::copy(_cursors.begin(), _cursors.end(), inserter(*in, in->begin()));
}
+
+ {
+ stdx::lock_guard<stdx::mutex> sl(_envStatMutex);
+ _getCursorsCallCount++;
+ _cursorsCallCountUpdatedCV.notify_one();
+ }
+}
}