-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.hpp
More file actions
78 lines (62 loc) · 2.17 KB
/
Copy pathoptions.hpp
File metadata and controls
78 lines (62 loc) · 2.17 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Copyright 2025, Aleksandar Colic
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#ifndef OPTIONS_HPP
#define OPTIONS_HPP
#include <algorithm>
#include <cstdint>
#include "config.hpp"
#include "types.hpp"
namespace ums {
class Options {
public:
class Option {
public:
Option(u64 value, u64 min, u64 max) noexcept : m_value{std::clamp(value, min, max)} {}
operator u64() const noexcept { return m_value; } // NOLINT
private:
u64 m_value;
};
struct Schedulers_count : Option {
explicit Schedulers_count(u64 value = CFG_default_schedulers_count) noexcept
: Option{value, CFG_min_schedulers_count, CFG_max_schedulers_count}
{
}
};
struct Workers_per_scheduler : Option {
explicit Workers_per_scheduler(u64 value = CFG_default_workers_per_scheduler) noexcept
: Option{value, CFG_min_workers_per_scheduler, CFG_max_workers_per_scheduler}
{
}
};
explicit Options(Schedulers_count schedulers_count = Schedulers_count{},
Workers_per_scheduler workers_per_scheduler = Workers_per_scheduler{}) noexcept
: m_schedulers_count{schedulers_count}
, m_workers_per_scheduler{workers_per_scheduler}
{
}
Schedulers_count schedulers_count() { return m_schedulers_count; }
Workers_per_scheduler workers_per_scheduler() { return m_workers_per_scheduler; }
private:
// Maximum number of schedulers that will be created.
//
Schedulers_count m_schedulers_count;
// Number of workers per scheduler.
//
Workers_per_scheduler m_workers_per_scheduler;
};
} // namespace ums
#endif // OPTIONS_HPP