summaryrefslogtreecommitdiff
path: root/src/mongo/db/query
diff options
context:
space:
mode:
authorWaley Chen <waleycz@gmail.com>2016-05-02 21:40:41 -0400
committerWaley Chen <waleycz@gmail.com>2016-05-02 21:40:41 -0400
commit8abd5682f551ad79dec3557f721eebd45b21be0f (patch)
treee3430994fdf46a4cce8f40ce2f6e621c477065f3 /src/mongo/db/query
parent21cfba12a005431b08a8c69dcdb1f262622ea780 (diff)
downloadmongo-8abd5682f551ad79dec3557f721eebd45b21be0f.tar.gz
SERVER-23243 Replace Listener::getElapsedTimeMillis() in elapsed_tracker.cpp
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r--src/mongo/db/query/plan_yield_policy.cpp14
-rw-r--r--src/mongo/db/query/plan_yield_policy.h7
2 files changed, 20 insertions, 1 deletions
diff --git a/src/mongo/db/query/plan_yield_policy.cpp b/src/mongo/db/query/plan_yield_policy.cpp
index b03ec44920b..575ebf664b8 100644
--- a/src/mongo/db/query/plan_yield_policy.cpp
+++ b/src/mongo/db/query/plan_yield_policy.cpp
@@ -35,16 +35,28 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/query/query_yield.h"
+#include "mongo/db/service_context.h"
#include "mongo/util/scopeguard.h"
+#include "mongo/util/time_support.h"
namespace mongo {
PlanYieldPolicy::PlanYieldPolicy(PlanExecutor* exec, PlanExecutor::YieldPolicy policy)
: _policy(policy),
_forceYield(false),
- _elapsedTracker(internalQueryExecYieldIterations, internalQueryExecYieldPeriodMS),
+ _elapsedTracker(exec->getOpCtx()->getServiceContext()->getFastClockSource(),
+ internalQueryExecYieldIterations,
+ Milliseconds(internalQueryExecYieldPeriodMS)),
_planYielding(exec) {}
+
+PlanYieldPolicy::PlanYieldPolicy(PlanExecutor::YieldPolicy policy, ClockSource* cs)
+ : _policy(policy),
+ _forceYield(false),
+ _elapsedTracker(
+ cs, internalQueryExecYieldIterations, Milliseconds(internalQueryExecYieldPeriodMS)),
+ _planYielding(nullptr) {}
+
bool PlanYieldPolicy::shouldYield() {
if (!allowedToYield())
return false;
diff --git a/src/mongo/db/query/plan_yield_policy.h b/src/mongo/db/query/plan_yield_policy.h
index 0de47c608cd..ec6dca7a0f2 100644
--- a/src/mongo/db/query/plan_yield_policy.h
+++ b/src/mongo/db/query/plan_yield_policy.h
@@ -34,6 +34,7 @@
namespace mongo {
+class ClockSource;
class RecordFetcher;
class PlanYieldPolicy {
@@ -44,6 +45,12 @@ public:
* locks.
*/
PlanYieldPolicy(PlanExecutor* exec, PlanExecutor::YieldPolicy policy);
+ /**
+ * Only used in dbtests since we don't have access to a PlanExecutor. Since we don't have
+ * access to the PlanExecutor to grab a ClockSource from, we pass in a ClockSource directly
+ * in the constructor instead.
+ */
+ PlanYieldPolicy(PlanExecutor::YieldPolicy policy, ClockSource* cs);
/**
* Used by YIELD_AUTO plan executors in order to check whether it is time to yield.