diff options
author | Benety Goh <benety@mongodb.com> | 2020-10-16 13:56:28 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-16 18:14:20 +0000 |
commit | b179b1b261591857523ee332d220842615b9c8c6 (patch) | |
tree | aac3a28cca0db2b6eeebcc1bd0ef08c3385b5bc4 /src/mongo/db/repl_index_build_state.cpp | |
parent | af298544ba207890ef3dc9da9b5b7db8e17eb2bb (diff) | |
download | mongo-b179b1b261591857523ee332d220842615b9c8c6.tar.gz |
SERVER-46995 add methods for synchronizing IndexBuildAction to ReplIndexBuildState
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(); |