summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/concurrency')
-rw-r--r--src/mongo/db/concurrency/lock_state.cpp7
-rw-r--r--src/mongo/db/concurrency/lock_state.h1
-rw-r--r--src/mongo/db/concurrency/locker.h6
-rw-r--r--src/mongo/db/concurrency/locker_noop.h4
4 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp
index 6e9c5932305..eaedc2f3f3f 100644
--- a/src/mongo/db/concurrency/lock_state.cpp
+++ b/src/mongo/db/concurrency/lock_state.cpp
@@ -602,6 +602,13 @@ void LockerImpl<IsForMMAPV1>::getLockerInfo(LockerInfo* lockerInfo) const {
}
template <bool IsForMMAPV1>
+boost::optional<Locker::LockerInfo> LockerImpl<IsForMMAPV1>::getLockerInfo() const {
+ Locker::LockerInfo lockerInfo;
+ getLockerInfo(&lockerInfo);
+ return std::move(lockerInfo);
+}
+
+template <bool IsForMMAPV1>
bool LockerImpl<IsForMMAPV1>::saveLockStateAndUnlock(Locker::LockSnapshot* stateOut) {
// We shouldn't be saving and restoring lock state from inside a WriteUnitOfWork.
invariant(!inAWriteUnitOfWork());
diff --git a/src/mongo/db/concurrency/lock_state.h b/src/mongo/db/concurrency/lock_state.h
index 27ca6a39bac..1083d4c25ca 100644
--- a/src/mongo/db/concurrency/lock_state.h
+++ b/src/mongo/db/concurrency/lock_state.h
@@ -172,6 +172,7 @@ public:
virtual ResourceId getWaitingResource() const;
virtual void getLockerInfo(LockerInfo* lockerInfo) const;
+ virtual boost::optional<LockerInfo> getLockerInfo() const final;
virtual bool saveLockStateAndUnlock(LockSnapshot* stateOut);
diff --git a/src/mongo/db/concurrency/locker.h b/src/mongo/db/concurrency/locker.h
index d90b8916289..8d98b123f72 100644
--- a/src/mongo/db/concurrency/locker.h
+++ b/src/mongo/db/concurrency/locker.h
@@ -287,6 +287,12 @@ public:
virtual void getLockerInfo(LockerInfo* lockerInfo) const = 0;
/**
+ * Returns boost::none if this is an instance of LockerNoop, or a populated LockerInfo
+ * otherwise.
+ */
+ virtual boost::optional<LockerInfo> getLockerInfo() const = 0;
+
+ /**
* LockSnapshot captures the state of all resources that are locked, what modes they're
* locked in, and how many times they've been locked in that mode.
*/
diff --git a/src/mongo/db/concurrency/locker_noop.h b/src/mongo/db/concurrency/locker_noop.h
index c86b90e7cbd..7a66fa84687 100644
--- a/src/mongo/db/concurrency/locker_noop.h
+++ b/src/mongo/db/concurrency/locker_noop.h
@@ -149,6 +149,10 @@ public:
MONGO_UNREACHABLE;
}
+ virtual boost::optional<LockerInfo> getLockerInfo() const {
+ return boost::none;
+ }
+
virtual bool saveLockStateAndUnlock(LockSnapshot* stateOut) {
MONGO_UNREACHABLE;
}