Kea: cfg_multi_threading.cc Source File

| Kea 3.2.0-git

cfg_multi_threading.cc
Go to the documentation of this file.
1// Copyright (C) 2020-2023 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <cc/data.h>
10#include <cc/simple_parser.h>
11#include <cfg_multi_threading.h>
12#include <util/multi_threading_mgr.h>
13
14using namespace isc::data;
15using namespace isc::util;
16
17namespace isc {
18namespace dhcp {
19
20void
21CfgMultiThreading::apply(ConstElementPtr value) {
22 // Note the default values are set by extract, not here!
23 bool enabled = false;
24 uint32_t thread_count = 0;
25 uint32_t queue_size = 0;
26 CfgMultiThreading::extract(value, enabled, thread_count, queue_size);
27 MultiThreadingMgr::instance().apply(enabled, thread_count, queue_size);
28}
29
30void
31CfgMultiThreading::extract(ConstElementPtr value, bool& enabled,
32 uint32_t& thread_count, uint32_t& queue_size) {
33 enabled = true;
34 thread_count = 0;
35 queue_size = 0;
36 if (value) {
37 if (value->get("enable-multi-threading")) {
38 enabled = SimpleParser::getBoolean(value, "enable-multi-threading");
39 }
40
41 if (value->get("thread-pool-size")) {
42 thread_count = SimpleParser::getInteger(value, "thread-pool-size");
43 }
44
45 if (value->get("packet-queue-size")) {
46 queue_size = SimpleParser::getInteger(value, "packet-queue-size");
47 }
48 }
49}
50
51} // namespace dhcp
52} // namespace isc
cfg_multi_threading.h
isc::data::SimpleParser::getBoolean
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
Definition lib/cc/simple_parser.cc:108
isc::data::SimpleParser::getInteger
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
Definition lib/cc/simple_parser.cc:77
isc::dhcp::CfgMultiThreading::apply
static void apply(data::ConstElementPtr value)
apply multi threading configuration
Definition cfg_multi_threading.cc:21
isc::dhcp::CfgMultiThreading::extract
static void extract(data::ConstElementPtr value, bool &enabled, uint32_t &thread_count, uint32_t &queue_size)
Extract multi-threading parameters from a given configuration.
Definition cfg_multi_threading.cc:31
isc::util::MultiThreadingMgr::instance
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
Definition multi_threading_mgr.cc:25
isc::util::MultiThreadingMgr::apply
void apply(bool enabled, uint32_t thread_count, uint32_t queue_size)
Apply the multi-threading related settings.
Definition multi_threading_mgr.cc:124
data.h
simple_parser.h
multi_threading_mgr.h
isc::data
Definition base_stamped_element.cc:12
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::util
Definition time_utils.cc:43
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18