summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/cfg_multi_threading.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/dhcpsrv/cfg_multi_threading.cc')
-rw-r--r--src/lib/dhcpsrv/cfg_multi_threading.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/lib/dhcpsrv/cfg_multi_threading.cc b/src/lib/dhcpsrv/cfg_multi_threading.cc
new file mode 100644
index 0000000..c31e6a7
--- /dev/null
+++ b/src/lib/dhcpsrv/cfg_multi_threading.cc
@@ -0,0 +1,51 @@
+// Copyright (C) 2020-2021 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+
+#include <cc/data.h>
+#include <cc/simple_parser.h>
+#include <cfg_multi_threading.h>
+#include <util/multi_threading_mgr.h>
+
+using namespace isc::data;
+using namespace isc::util;
+
+namespace isc {
+namespace dhcp {
+
+void
+CfgMultiThreading::apply(ConstElementPtr value) {
+ bool enabled = false;
+ uint32_t thread_count = 0;
+ uint32_t queue_size = 0;
+ CfgMultiThreading::extract(value, enabled, thread_count, queue_size);
+ MultiThreadingMgr::instance().apply(enabled, thread_count, queue_size);
+}
+
+void
+CfgMultiThreading::extract(ConstElementPtr value, bool& enabled,
+ uint32_t& thread_count, uint32_t& queue_size) {
+ enabled = false;
+ thread_count = 0;
+ queue_size = 0;
+ if (value) {
+ if (value->get("enable-multi-threading")) {
+ enabled = SimpleParser::getBoolean(value, "enable-multi-threading");
+ }
+
+ if (value->get("thread-pool-size")) {
+ thread_count = SimpleParser::getInteger(value, "thread-pool-size");
+ }
+
+ if (value->get("packet-queue-size")) {
+ queue_size = SimpleParser::getInteger(value, "packet-queue-size");
+ }
+ }
+}
+
+} // namespace dhcp
+} // namespace isc