summaryrefslogtreecommitdiffstats
path: root/library/cpp/http/server
diff options
context:
space:
mode:
Diffstat (limited to 'library/cpp/http/server')
-rw-r--r--library/cpp/http/server/http.cpp30
-rw-r--r--library/cpp/http/server/options.h6
2 files changed, 26 insertions, 10 deletions
diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp
index 2dd407dceff..ecdd93ab56e 100644
--- a/library/cpp/http/server/http.cpp
+++ b/library/cpp/http/server/http.cpp
@@ -2,6 +2,7 @@
#include "http_ex.h"
#include <library/cpp/threading/equeue/equeue.h>
+#include <library/cpp/threading/equeue/fast.h>
#include <util/generic/buffer.h>
#include <util/generic/intrlist.h>
@@ -405,8 +406,8 @@ public:
: TImpl(
parent,
cb,
- MakeThreadPool<TSimpleThreadPool>(factory, options.UseElasticQueues, cb, options.RequestsThreadName),
- MakeThreadPool<TThreadPool>(factory, options.UseElasticQueues, nullptr, options.FailRequestsThreadName),
+ MakeThreadPool<TSimpleThreadPool>(factory, options, cb, options.RequestsThreadName),
+ MakeThreadPool<TThreadPool>(factory, options, nullptr, options.FailRequestsThreadName),
options) {
}
@@ -456,21 +457,30 @@ public:
private:
template <class TThreadPool_>
- static THolder<IThreadPool> MakeThreadPool(IThreadFactory* factory, bool elastic, ICallBack* callback = nullptr, const TString& threadName = {}) {
+ static THolder<IThreadPool> MakeThreadPool(ICallBack* callback, const IThreadPool::TParams& params) {
+ if (callback) {
+ return MakeHolder<TThreadPoolBinder<TThreadPool_, THttpServer::ICallBack>>(callback, params);
+ } else {
+ return MakeHolder<TThreadPool_>(params);
+ }
+ }
+
+ template <class TThreadPool_>
+ static THolder<IThreadPool> MakeThreadPool(IThreadFactory* factory, const TOptions& options, ICallBack* callback = nullptr, const TString& threadName = {}) {
if (!factory) {
factory = SystemThreadFactory();
}
THolder<IThreadPool> pool;
const auto params = IThreadPool::TParams().SetFactory(factory).SetThreadName(threadName);
- if (callback) {
- pool = MakeHolder<TThreadPoolBinder<TThreadPool_, THttpServer::ICallBack>>(callback, params);
- } else {
- pool = MakeHolder<TThreadPool_>(params);
- }
- if (elastic) {
- pool = MakeHolder<TElasticQueue>(std::move(pool));
+ if (options.UseFastElasticQueues) {
+ pool = MakeThreadPool<TFastElasticQueue>(callback, params);
+ } else {
+ pool = MakeThreadPool<TThreadPool_>(callback, params);
+ if (options.UseElasticQueues) {
+ pool = MakeHolder<TElasticQueue>(std::move(pool));
+ }
}
return pool;
diff --git a/library/cpp/http/server/options.h b/library/cpp/http/server/options.h
index 5976d58f32f..4656dd7082e 100644
--- a/library/cpp/http/server/options.h
+++ b/library/cpp/http/server/options.h
@@ -131,6 +131,11 @@ public:
return *this;
}
+ inline THttpServerOptions& EnableFastElasticQueues(bool enable) noexcept {
+ UseFastElasticQueues = enable;
+
+ return *this;
+ }
inline THttpServerOptions& SetThreadsName(const TString& listenThreadName, const TString& requestsThreadName, const TString& failRequestsThreadName) noexcept {
ListenThreadName = listenThreadName;
RequestsThreadName = requestsThreadName;
@@ -167,6 +172,7 @@ public:
ui64 MaxInputContentLength = sizeof(size_t) <= 4 ? 2_GB : 64_GB;
size_t MaxRequestsPerConnection = 0; // If keep-alive is enabled, request limit before connection is closed
bool UseElasticQueues = false;
+ bool UseFastElasticQueues = false;
TDuration PollTimeout; // timeout of TSocketPoller::WaitT call
TDuration ExpirationTimeout; // drop inactive connections after ExpirationTimeout (should be > 0)