summaryrefslogtreecommitdiff
path: root/src/mongo/client/query_fetcher.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/client/query_fetcher.h')
-rw-r--r--src/mongo/client/query_fetcher.h98
1 files changed, 54 insertions, 44 deletions
diff --git a/src/mongo/client/query_fetcher.h b/src/mongo/client/query_fetcher.h
index 3ac11191e02..bd79f6e133d 100644
--- a/src/mongo/client/query_fetcher.h
+++ b/src/mongo/client/query_fetcher.h
@@ -37,55 +37,65 @@
namespace mongo {
- struct HostAndPort;
- class NamespaceString;
- class BSONObj;
- class BSONObjBuilder;
+struct HostAndPort;
+class NamespaceString;
+class BSONObj;
+class BSONObjBuilder;
- /**
- * Follows the fetcher pattern for a find+getmore.
- * QueryFetcher will continue to call getmore until an error or
- * until the last batch of results.
- */
- class QueryFetcher {
- MONGO_DISALLOW_COPYING(QueryFetcher);
- public:
- using CallbackFn =
- stdx::function<void (const Fetcher::QueryResponseStatus&, Fetcher::NextAction*)>;
+/**
+ * Follows the fetcher pattern for a find+getmore.
+ * QueryFetcher will continue to call getmore until an error or
+ * until the last batch of results.
+ */
+class QueryFetcher {
+ MONGO_DISALLOW_COPYING(QueryFetcher);
- QueryFetcher(executor::TaskExecutor* exec,
- const HostAndPort& source,
- const NamespaceString& nss,
- const BSONObj& cmdBSON,
- const QueryFetcher::CallbackFn& onBatchAvailable);
- virtual ~QueryFetcher() = default;
+public:
+ using CallbackFn =
+ stdx::function<void(const Fetcher::QueryResponseStatus&, Fetcher::NextAction*)>;
- bool isActive() const { return _fetcher.isActive(); }
- Status schedule() { return _fetcher.schedule(); }
- void cancel() { return _fetcher.cancel(); }
- void wait() { if (_fetcher.isActive()) _fetcher.wait(); }
- std::string getDiagnosticString() const;
+ QueryFetcher(executor::TaskExecutor* exec,
+ const HostAndPort& source,
+ const NamespaceString& nss,
+ const BSONObj& cmdBSON,
+ const QueryFetcher::CallbackFn& onBatchAvailable);
+ virtual ~QueryFetcher() = default;
- protected:
- int _getResponses() const;
- void _onFetchCallback(const Fetcher::QueryResponseStatus& fetchResult,
- Fetcher::NextAction* nextAction,
- BSONObjBuilder* getMoreBob);
+ bool isActive() const {
+ return _fetcher.isActive();
+ }
+ Status schedule() {
+ return _fetcher.schedule();
+ }
+ void cancel() {
+ return _fetcher.cancel();
+ }
+ void wait() {
+ if (_fetcher.isActive())
+ _fetcher.wait();
+ }
+ std::string getDiagnosticString() const;
- /**
- * Called by _delegateCallback() to forward query results to '_work'.
- */
- void _onQueryResponse(const Fetcher::QueryResponseStatus& fetchResult,
- Fetcher::NextAction* nextAction);
+protected:
+ int _getResponses() const;
+ void _onFetchCallback(const Fetcher::QueryResponseStatus& fetchResult,
+ Fetcher::NextAction* nextAction,
+ BSONObjBuilder* getMoreBob);
+
+ /**
+ * Called by _delegateCallback() to forward query results to '_work'.
+ */
+ void _onQueryResponse(const Fetcher::QueryResponseStatus& fetchResult,
+ Fetcher::NextAction* nextAction);
- virtual void _delegateCallback(const Fetcher::QueryResponseStatus& fetchResult,
- Fetcher::NextAction* nextAction);
+ virtual void _delegateCallback(const Fetcher::QueryResponseStatus& fetchResult,
+ Fetcher::NextAction* nextAction);
- private:
- executor::TaskExecutor* _exec;
- Fetcher _fetcher;
- int _responses;
- const QueryFetcher::CallbackFn _work;
- };
+private:
+ executor::TaskExecutor* _exec;
+ Fetcher _fetcher;
+ int _responses;
+ const QueryFetcher::CallbackFn _work;
+};
-} // namespace mongo
+} // namespace mongo