summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/util/concurrency/ticketholder.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/util/concurrency/ticketholder.cpp b/src/mongo/util/concurrency/ticketholder.cpp
index 45bf7e51bc2..d087b215da4 100644
--- a/src/mongo/util/concurrency/ticketholder.cpp
+++ b/src/mongo/util/concurrency/ticketholder.cpp
@@ -95,6 +95,11 @@ void TicketHolder::waitForTicket(OperationContext* opCtx) {
}
bool TicketHolder::waitForTicketUntil(OperationContext* opCtx, Date_t until) {
+ // Attempt to get a ticket without waiting in order to avoid expensive time calculations.
+ if (sem_trywait(&_sem) == 0) {
+ return true;
+ }
+
const Milliseconds intervalMs(500);
struct timespec ts;