diff options
author | Reo Kimura <reo.kimura@mongodb.com> | 2020-07-22 03:03:43 +0000 |
---|---|---|
committer | Reo Kimura <reo.kimura@mongodb.com> | 2020-08-07 18:51:05 +0000 |
commit | 120b213146dc93d8777371650d082dd15b1a1c0b (patch) | |
tree | e9c961f52fc308429d188bbb5e61dffbd01d1e21 /src/mongo/transport/service_executor_reserved.cpp | |
parent | 9238911d0a46f26419ecdbec4293457b9e1a891d (diff) | |
download | mongo-server-49072.tar.gz |
SERVER-49072 Created SE decorations, rewrote SEPI start/shutdown of SEsserver-49072
Diffstat (limited to 'src/mongo/transport/service_executor_reserved.cpp')
-rw-r--r-- | src/mongo/transport/service_executor_reserved.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mongo/transport/service_executor_reserved.cpp b/src/mongo/transport/service_executor_reserved.cpp index f262f030583..35db496e279 100644 --- a/src/mongo/transport/service_executor_reserved.cpp +++ b/src/mongo/transport/service_executor_reserved.cpp @@ -33,6 +33,7 @@ #include "mongo/transport/service_executor_reserved.h" +#include "mongo/db/server_options.h" #include "mongo/logv2/log.h" #include "mongo/stdx/thread.h" #include "mongo/transport/service_entry_point_utils.h" @@ -147,6 +148,20 @@ Status ServiceExecutorReserved::_startWorker() { }); } +const auto getServiceExecutorReserved = + ServiceContext::declareDecoration<std::unique_ptr<ServiceExecutorReserved>>(); + +ServiceExecutorReserved* ServiceExecutorReserved::get(ServiceContext* ctx) { + auto& ref = getServiceExecutorReserved(ctx); + if (!ref) { + if (serverGlobalParams.reservedAdminThreads) { + ref = std::make_unique<transport::ServiceExecutorReserved>( + ctx, "admin/internal connections", serverGlobalParams.reservedAdminThreads); + } else + return nullptr; + } + return ref.get(); +} Status ServiceExecutorReserved::shutdown(Milliseconds timeout) { LOGV2_DEBUG(22980, 3, "Shutting down reserved executor"); @@ -173,8 +188,8 @@ Status ServiceExecutorReserved::schedule(Task task, ScheduleFlags flags) { if (!_localWorkQueue.empty()) { // Execute task directly (recurse) if allowed by the caller as it produced better // performance in testing. Try to limit the amount of recursion so we don't blow up the - // stack, even though this shouldn't happen with this executor that uses blocking network - // I/O. + // stack, even though this shouldn't happen with this executor that uses blocking + // network I/O. if ((flags & ScheduleFlags::kMayRecurse) && (_localRecursionDepth < reservedServiceExecutorRecursionLimit.loadRelaxed())) { ++_localRecursionDepth; |