Kea 2.7.0
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>
13
14using namespace isc::data;
15using namespace isc::util;
16
17namespace isc {
18namespace dhcp {
19
20void
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
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
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
static void apply(data::ConstElementPtr value)
apply multi threading configuration
static void extract(data::ConstElementPtr value, bool &enabled, uint32_t &thread_count, uint32_t &queue_size)
Extract multi-threading parameters from a given configuration.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
Defines the logger used by the top-level component of kea-lfc.