diff options
author | Misha Tyulenev <misha@mongodb.com> | 2017-07-19 15:10:51 -0400 |
---|---|---|
committer | Misha Tyulenev <misha@mongodb.com> | 2017-07-19 17:19:56 -0400 |
commit | e034bdc4be7de0326d34e982febf00505cf0d993 (patch) | |
tree | 7cb5dfd3c03194bb3e811f7e6eb6552b28373888 /src/mongo/db/operation_time_tracker.cpp | |
parent | ce1dbc96feb5ba8bf7f60cacdea1ddc77a1a5556 (diff) | |
download | mongo-e034bdc4be7de0326d34e982febf00505cf0d993.tar.gz |
SERVER-29700 add operationTime in all connections used by mongos
Diffstat (limited to 'src/mongo/db/operation_time_tracker.cpp')
-rw-r--r-- | src/mongo/db/operation_time_tracker.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/mongo/db/operation_time_tracker.cpp b/src/mongo/db/operation_time_tracker.cpp index fc245db99ad..0b4d3dc677a 100644 --- a/src/mongo/db/operation_time_tracker.cpp +++ b/src/mongo/db/operation_time_tracker.cpp @@ -33,18 +33,20 @@ namespace mongo { namespace { -auto getOperationTimeTracker = - OperationContext::declareDecoration<std::shared_ptr<OperationTimeTracker>>(); -} +struct OperationTimeTrackerHolder { + OperationTimeTrackerHolder() : opTimeTracker(std::make_shared<OperationTimeTracker>()) {} + static const OperationContext::Decoration<OperationTimeTrackerHolder> get; + std::shared_ptr<OperationTimeTracker> opTimeTracker; +}; -std::shared_ptr<OperationTimeTracker> OperationTimeTracker::get(OperationContext* opCtx) { - return getOperationTimeTracker(opCtx); +const OperationContext::Decoration<OperationTimeTrackerHolder> OperationTimeTrackerHolder::get = + OperationContext::declareDecoration<OperationTimeTrackerHolder>(); } -void OperationTimeTracker::set(OperationContext* opCtx, - std::shared_ptr<OperationTimeTracker> trackerArg) { - auto& tracker = getOperationTimeTracker(opCtx); - tracker = std::move(trackerArg); +std::shared_ptr<OperationTimeTracker> OperationTimeTracker::get(OperationContext* opCtx) { + auto timeTrackerHolder = OperationTimeTrackerHolder::get(opCtx); + invariant(timeTrackerHolder.opTimeTracker); + return timeTrackerHolder.opTimeTracker; } LogicalTime OperationTimeTracker::getMaxOperationTime() const { |