diff options
Diffstat (limited to 'src/mongo/db/repl/topology_version_observer.h')
-rw-r--r-- | src/mongo/db/repl/topology_version_observer.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mongo/db/repl/topology_version_observer.h b/src/mongo/db/repl/topology_version_observer.h index 66872d2a087..ff5c2e8564f 100644 --- a/src/mongo/db/repl/topology_version_observer.h +++ b/src/mongo/db/repl/topology_version_observer.h @@ -93,6 +93,16 @@ public: std::string toString() const; + /** + * Returns true if this TopologyVersionObserver background thread has stopped. + * + * Note that this funtion only returns true after _thread has started and ended, thus implies + * that getCached() will never return a valid IsMasterResponse again. + */ + bool isShutdown() const noexcept { + return _state.loadRelaxed() == State::kShutdown; + } + private: enum class State { kUninitialized, @@ -100,7 +110,7 @@ private: kShutdown, }; - void _cacheIsMasterResponse(OperationContext*, boost::optional<TopologyVersion>) noexcept; + void _cacheIsMasterResponse(OperationContext*, boost::optional<TopologyVersion>); void _workerThreadBody() noexcept; |