summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/persistent_task_queue.h
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2022-09-21 13:20:19 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-21 14:06:27 +0000
commit5272f5854d1954820e859ebbbaf0b030e80dc32c (patch)
tree1403d11c4401e197acb6b17c080f6c6e49398909 /src/mongo/db/s/persistent_task_queue.h
parent45c59ca2dbd0f2d316cc0a3d80ab787eb7e418f3 (diff)
downloadmongo-5272f5854d1954820e859ebbbaf0b030e80dc32c.tar.gz
SERVER-69727 Make ResourceLock acquisitions in the PersistentTaskQueue interruptible
Diffstat (limited to 'src/mongo/db/s/persistent_task_queue.h')
-rw-r--r--src/mongo/db/s/persistent_task_queue.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mongo/db/s/persistent_task_queue.h b/src/mongo/db/s/persistent_task_queue.h
index c8d94b4bdf6..2bd70140bc6 100644
--- a/src/mongo/db/s/persistent_task_queue.h
+++ b/src/mongo/db/s/persistent_task_queue.h
@@ -124,7 +124,7 @@ TaskId PersistentTaskQueue<T>::push(OperationContext* opCtx, const T& t) {
BSONObjBuilder builder;
{
- Lock::ExclusiveLock lock(opCtx->lockState(), _mutex);
+ Lock::ExclusiveLock lock(opCtx, _mutex);
uassert(ErrorCodes::Interrupted, "Task queue was closed", !_closed);
@@ -148,7 +148,7 @@ TaskId PersistentTaskQueue<T>::pop(OperationContext* opCtx) {
DBDirectClient client(opCtx);
BSONObjBuilder builder;
- Lock::ExclusiveLock lock(opCtx->lockState(), _mutex);
+ Lock::ExclusiveLock lock(opCtx, _mutex);
uassert(ErrorCodes::Interrupted, "Task queue was closed", !_closed);
@@ -170,8 +170,7 @@ TaskId PersistentTaskQueue<T>::pop(OperationContext* opCtx) {
template <typename T>
const typename BlockingTaskQueue<T>::Record& PersistentTaskQueue<T>::peek(OperationContext* opCtx) {
- Lock::ExclusiveLock lock(opCtx->lockState(), _mutex);
-
+ Lock::ExclusiveLock lock(opCtx, _mutex);
opCtx->waitForConditionOrInterrupt(_cv, lock, [this] { return _count > 0 || _closed; });
uassert(ErrorCodes::Interrupted, "Task queue was closed", !_closed);
@@ -184,7 +183,7 @@ const typename BlockingTaskQueue<T>::Record& PersistentTaskQueue<T>::peek(Operat
template <typename T>
void PersistentTaskQueue<T>::close(OperationContext* opCtx) {
- Lock::ExclusiveLock lock(opCtx->lockState(), _mutex);
+ Lock::ExclusiveLock lock(opCtx, _mutex);
_closed = true;
_cv.notify_all();
@@ -192,14 +191,14 @@ void PersistentTaskQueue<T>::close(OperationContext* opCtx) {
template <typename T>
size_t PersistentTaskQueue<T>::size(OperationContext* opCtx) const {
- Lock::ExclusiveLock lock(opCtx->lockState(), _mutex);
+ Lock::ExclusiveLock lock(opCtx, _mutex);
return _count;
}
template <typename T>
bool PersistentTaskQueue<T>::empty(OperationContext* opCtx) const {
- Lock::ExclusiveLock lock(opCtx->lockState(), _mutex);
+ Lock::ExclusiveLock lock(opCtx, _mutex);
return _count == 0;
}