diff options
-rw-r--r-- | src/mongo/db/service_context.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/service_context.h | 9 | ||||
-rw-r--r-- | src/mongo/db/service_context_d.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/server.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/sharding_test_fixture.cpp | 2 |
5 files changed, 13 insertions, 8 deletions
diff --git a/src/mongo/db/service_context.cpp b/src/mongo/db/service_context.cpp index 1a6f3751096..075fafd7360 100644 --- a/src/mongo/db/service_context.cpp +++ b/src/mongo/db/service_context.cpp @@ -148,15 +148,15 @@ TickSource* ServiceContext::getTickSource() const { } ClockSource* ServiceContext::getPreciseClockSource() const { - return _clockSource.get(); + return _preciseClockSource.get(); } void ServiceContext::setTickSource(std::unique_ptr<TickSource> newSource) { _tickSource = std::move(newSource); } -void ServiceContext::setClockSource(std::unique_ptr<ClockSource> newSource) { - _clockSource = std::move(newSource); +void ServiceContext::setPreciseClockSource(std::unique_ptr<ClockSource> newSource) { + _preciseClockSource = std::move(newSource); } void ServiceContext::ClientDeleter::operator()(Client* client) const { diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h index 08b4b55bdf5..4a5b54bb6c7 100644 --- a/src/mongo/db/service_context.h +++ b/src/mongo/db/service_context.h @@ -319,7 +319,12 @@ public: * destroyed. So make sure that no one is using the old source when calling this. */ void setTickSource(std::unique_ptr<TickSource> newSource); - void setClockSource(std::unique_ptr<ClockSource> newSource); + + /** + * Call this method with a ClockSource implementation that is very precise but + * may be expensive to call. + */ + void setPreciseClockSource(std::unique_ptr<ClockSource> newSource); protected: ServiceContext() = default; @@ -343,7 +348,7 @@ private: ClientSet _clients; std::unique_ptr<TickSource> _tickSource; - std::unique_ptr<ClockSource> _clockSource; + std::unique_ptr<ClockSource> _preciseClockSource; }; /** diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp index a79a3fdb4ac..c262e866d30 100644 --- a/src/mongo/db/service_context_d.cpp +++ b/src/mongo/db/service_context_d.cpp @@ -58,7 +58,7 @@ namespace mongo { MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) { setGlobalServiceContext(stdx::make_unique<ServiceContextMongoD>()); getGlobalServiceContext()->setTickSource(stdx::make_unique<SystemTickSource>()); - getGlobalServiceContext()->setClockSource(stdx::make_unique<SystemClockSource>()); + getGlobalServiceContext()->setPreciseClockSource(stdx::make_unique<SystemClockSource>()); return Status::OK(); } diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp index 578c3a5df28..1bcab1a9f62 100644 --- a/src/mongo/s/server.cpp +++ b/src/mongo/s/server.cpp @@ -394,7 +394,7 @@ MONGO_INITIALIZER(CreateAuthorizationExternalStateFactory)(InitializerContext* c MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) { setGlobalServiceContext(stdx::make_unique<ServiceContextNoop>()); getGlobalServiceContext()->setTickSource(stdx::make_unique<SystemTickSource>()); - getGlobalServiceContext()->setClockSource(stdx::make_unique<SystemClockSource>()); + getGlobalServiceContext()->setPreciseClockSource(stdx::make_unique<SystemClockSource>()); return Status::OK(); } diff --git a/src/mongo/s/sharding_test_fixture.cpp b/src/mongo/s/sharding_test_fixture.cpp index 0121c22762a..f2b168621e6 100644 --- a/src/mongo/s/sharding_test_fixture.cpp +++ b/src/mongo/s/sharding_test_fixture.cpp @@ -81,7 +81,7 @@ const stdx::chrono::seconds ShardingTestFixture::kFutureTimeout{5}; void ShardingTestFixture::setUp() { _service = stdx::make_unique<ServiceContextNoop>(); - _service->setClockSource(stdx::make_unique<ClockSourceMock>()); + _service->setPreciseClockSource(stdx::make_unique<ClockSourceMock>()); _messagePort = stdx::make_unique<MessagingPortMock>(); _client = _service->makeClient("ShardingTestFixture", _messagePort.get()); _opCtx = _client->makeOperationContext(); |