Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
threading_config.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cstddef>
7
8namespace contur {
9
12 {
14 std::size_t hostThreadCount = 1;
15
17 bool deterministicMode = true;
18
20 bool workStealingEnabled = false;
21
23 [[nodiscard]] constexpr bool isValid() const noexcept
24 {
25 return hostThreadCount >= 1U;
26 }
27
29 [[nodiscard]] constexpr bool isSingleThreaded() const noexcept
30 {
31 return hostThreadCount == 1U;
32 }
33
35 [[nodiscard]] constexpr HostThreadingConfig normalized() const noexcept
36 {
37 HostThreadingConfig normalizedConfig = *this;
38
39 if (normalizedConfig.hostThreadCount == 0U)
40 {
41 normalizedConfig.hostThreadCount = 1U;
42 }
43
44 if (normalizedConfig.isSingleThreaded())
45 {
46 normalizedConfig.workStealingEnabled = false;
47 }
48
49 return normalizedConfig;
50 }
51
53 constexpr void normalize() noexcept
54 {
55 *this = normalized();
56 }
57 };
58
59} // namespace contur
Definition block.h:15
Configuration for host-thread dispatch runtime behavior.
constexpr HostThreadingConfig normalized() const noexcept
Returns a normalized copy with safe baseline invariants.
constexpr bool isSingleThreaded() const noexcept
Returns true when the runtime is configured for a single host thread.
constexpr bool isValid() const noexcept
Returns true when this config satisfies minimum runtime requirements.
std::size_t hostThreadCount
Number of host worker threads (must be >= 1).
bool deterministicMode
Enables deterministic scheduling checkpoints for multithreaded runs.
bool workStealingEnabled
Enables work stealing between worker lanes when multithreading is active.
constexpr void normalize() noexcept
Normalizes this instance in place.