summaryrefslogtreecommitdiff
path: root/src/mongo/transport/service_executor.h
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2022-10-27 18:46:06 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-27 19:47:47 +0000
commit7b9c8c6a22e38fd34ca313bb0637615f3075f720 (patch)
treee22c17190689b8bb22b54741aae30196273394de /src/mongo/transport/service_executor.h
parent3fd2cc553a27067f4662a0708cd2e98cd122dffb (diff)
downloadmongo-7b9c8c6a22e38fd34ca313bb0637615f3075f720.tar.gz
SERVER-70863 ServiceExecutor::TaskRunner
Diffstat (limited to 'src/mongo/transport/service_executor.h')
-rw-r--r--src/mongo/transport/service_executor.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/mongo/transport/service_executor.h b/src/mongo/transport/service_executor.h
index a1bac34e93c..d6b53453ba6 100644
--- a/src/mongo/transport/service_executor.h
+++ b/src/mongo/transport/service_executor.h
@@ -42,33 +42,39 @@
#include "mongo/util/functional.h"
#include "mongo/util/out_of_line_executor.h"
-namespace mongo {
-namespace transport {
+namespace mongo::transport {
extern bool gInitialUseDedicatedThread;
/*
* This is the interface for all ServiceExecutors.
*/
-class ServiceExecutor : public OutOfLineExecutor {
+class ServiceExecutor {
public:
+ using Task = OutOfLineExecutor::Task;
+
+ class TaskRunner : public OutOfLineExecutor {
+ public:
+ /**
+ * Awaits the availability of incoming data for the specified session. On success, it will
+ * schedule the callback on current executor. Otherwise, it will invoke the callback with a
+ * non-okay status on the caller thread.
+ */
+ virtual void runOnDataAvailable(std::shared_ptr<Session> session, Task task) = 0;
+ };
+
static void shutdownAll(ServiceContext* serviceContext, Date_t deadline);
virtual ~ServiceExecutor() = default;
+ virtual std::unique_ptr<TaskRunner> makeTaskRunner() = 0;
+
/*
* Starts the ServiceExecutor. This may create threads even if no tasks are scheduled.
*/
virtual Status start() = 0;
/*
- * Awaits the availability of incoming data for the specified session. On success, it will
- * schedule the callback on current executor. Otherwise, it will invoke the callback with a
- * non-okay status on the caller thread.
- */
- virtual void runOnDataAvailable(const SessionHandle& session, Task onCompletionCallback) = 0;
-
- /*
* Stops and joins the ServiceExecutor. Any outstanding tasks will not be executed, and any
* associated callbacks waiting on I/O may get called with an error code.
*
@@ -78,14 +84,10 @@ public:
virtual size_t getRunningThreads() const = 0;
- /*
- * Appends statistics about task scheduling to a BSONObjBuilder for serverStatus output.
- */
+ /** Appends statistics about task scheduling to a BSONObjBuilder for serverStatus output. */
virtual void appendStats(BSONObjBuilder* bob) const = 0;
- /**
- * Yield if we have more threads than cores.
- */
+ /** Yield if this executor controls more threads than we have cores. */
void yieldIfAppropriate() const;
};
@@ -191,6 +193,4 @@ public:
size_t limitExempt = 0;
};
-} // namespace transport
-
-} // namespace mongo
+} // namespace mongo::transport