diff options
author | Leonardo Menti <leonardo.menti@mongodb.com> | 2022-08-08 14:00:14 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-08 15:10:13 +0000 |
commit | 946044896c10e239a61bc0bacb0533c57246a920 (patch) | |
tree | 126319cdf330de948d5cac79f945e522a6eb31b6 /src/mongo/util/concurrency/ticketholder.h | |
parent | 58703826eabe1351692fd0efa56d9d1665896b45 (diff) | |
download | mongo-946044896c10e239a61bc0bacb0533c57246a920.tar.gz |
SERVER-67905 Created PriorityTicketHolder that queues by 3 priority levels
Diffstat (limited to 'src/mongo/util/concurrency/ticketholder.h')
-rw-r--r-- | src/mongo/util/concurrency/ticketholder.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/util/concurrency/ticketholder.h b/src/mongo/util/concurrency/ticketholder.h index 7512e3908f3..66769f1c015 100644 --- a/src/mongo/util/concurrency/ticketholder.h +++ b/src/mongo/util/concurrency/ticketholder.h @@ -367,6 +367,8 @@ public: int available() const override final; + int queued() const override final; + private: bool _tryAcquireTicket(); @@ -400,6 +402,7 @@ private: QueueMutex _queueMutex; AtomicWord<int> _ticketsAvailable; + AtomicWord<int> _enqueuedElements; ServiceContext* _serviceContext; }; @@ -421,6 +424,22 @@ private: std::uint32_t _totalWeight; }; +class PriorityTicketHolder final : public SchedulingTicketHolder { +public: + explicit PriorityTicketHolder(int numTickets, ServiceContext* serviceContext); + +private: + enum class QueueType : unsigned int { + LowPriorityQueue = 0, + NormalPriorityQueue = 1, + QueueTypeSize = 2 + }; + + void _dequeueWaitingThread() override final; + + Queue& _getQueueToUse(OperationContext* opCtx, const AdmissionContext* admCtx) override final; +}; + /** * RAII-style movable token that gets generated when a ticket is acquired and is automatically * released when going out of scope. |