diff options
Diffstat (limited to 'src/mongo/db/repl_index_build_state.cpp')
-rw-r--r-- | src/mongo/db/repl_index_build_state.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mongo/db/repl_index_build_state.cpp b/src/mongo/db/repl_index_build_state.cpp index a05adeb21e8..1bcf3786ec5 100644 --- a/src/mongo/db/repl_index_build_state.cpp +++ b/src/mongo/db/repl_index_build_state.cpp @@ -359,6 +359,26 @@ void ReplIndexBuildState::clearVoteRequestCbk() { voteCmdCbkHandle = executor::TaskExecutor::CallbackHandle(); } +void ReplIndexBuildState::resetNextActionPromise() { + stdx::unique_lock<Latch> lk(mutex); + waitForNextAction = std::make_unique<SharedPromise<IndexBuildAction>>(); +} + +SharedSemiFuture<IndexBuildAction> ReplIndexBuildState::getNextActionFuture() const { + stdx::unique_lock<Latch> lk(mutex); + invariant(waitForNextAction, str::stream() << buildUUID); + return waitForNextAction->getFuture(); +} + +boost::optional<IndexBuildAction> ReplIndexBuildState::getNextActionNoWait() const { + stdx::unique_lock<Latch> lk(mutex); + auto future = waitForNextAction->getFuture(); + if (!future.isReady()) { + return boost::none; + } + return future.get(); +} + bool ReplIndexBuildState::isResumable() const { stdx::unique_lock<Latch> lk(mutex); return !_lastOpTimeBeforeInterceptors.isNull(); |