summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/cfg_multi_threading.cc
blob: c31e6a720f011f49c8bf48e1d629f7a8a295e6f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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