diff options
author | Amirsaman Memaripour <amirsaman.memaripour@mongodb.com> | 2020-12-09 19:35:14 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-09 22:18:59 +0000 |
commit | c8520d84cc7356d1a30858092ee79de4dd6dc163 (patch) | |
tree | 84217bf67d7fa39a030866c9c32e08118158431c /src/mongo/executor | |
parent | c7692fcb55476c5b7d1f17f10662935255637012 (diff) | |
download | mongo-c8520d84cc7356d1a30858092ee79de4dd6dc163.tar.gz |
SERVER-53305 Control AsyncRequestExecutor via ConstructorDestructorActions
Diffstat (limited to 'src/mongo/executor')
-rw-r--r-- | src/mongo/executor/async_request_executor.cpp | 5 | ||||
-rw-r--r-- | src/mongo/executor/async_request_executor.h | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/mongo/executor/async_request_executor.cpp b/src/mongo/executor/async_request_executor.cpp index cf535e864f6..93b7867f262 100644 --- a/src/mongo/executor/async_request_executor.cpp +++ b/src/mongo/executor/async_request_executor.cpp @@ -46,12 +46,15 @@ AsyncRequestExecutor::AsyncRequestExecutor(std::string name) : _name(std::move(n options.minThreads = 0; options.maxThreads = 1; _pool = std::make_unique<ThreadPool>(std::move(options)); +} + +void AsyncRequestExecutor::start() { _pool->startup(); LOGV2_DEBUG( 4910801, kDiagnosticLogLevel, "Started asynchronous request executor", "name"_attr = _name); } -AsyncRequestExecutor::~AsyncRequestExecutor() { +void AsyncRequestExecutor::stop() { _pool->shutdown(); _pool->join(); LOGV2_DEBUG( diff --git a/src/mongo/executor/async_request_executor.h b/src/mongo/executor/async_request_executor.h index a54e7848392..7a7f2f62cac 100644 --- a/src/mongo/executor/async_request_executor.h +++ b/src/mongo/executor/async_request_executor.h @@ -49,7 +49,13 @@ public: AsyncRequestExecutor(const AsyncRequestExecutor&) = delete; explicit AsyncRequestExecutor(std::string name); - ~AsyncRequestExecutor(); + + /** + * Wrap the startup and shutdown interfaces provided by `_pool` and delegate the concurrency + * control to corresponding member functions of `ThreadPool`. + */ + void start(); + void stop(); /** * Runs the command-specific code to handle the request. @@ -59,7 +65,7 @@ public: /** * Schedules the request on a thread pool (i.e., `_pool`) and calls into `handleRequest` to - * asynchronously execute the command. + * asynchronously execute the command. Note that the scheduled tasks run inline during shutdown. */ Future<void> schedule(std::shared_ptr<RequestExecutionContext> rec); |