NUMA++ 0.12.0
Loading...
Searching...
No Matches
schedulerExample1.cpp
Go to the documentation of this file.
1/**
2 * @file
3 * @copyright
4 * SPDX-FileCopyrightText: 2023-2023 European Southern Observatory (ESO)
5 *
6 * SPDX-License-Identifier: LGPL-3.0-only
7 */
8#include <iostream>
9#include <numapp/numa.hpp>
10#include <numapp/scheduler.hpp>
11
12int main() {
14 if (!numapp::NumaAvailable()) {
15 std::cout << "NUMA not available";
16 return -1;
17 }
18
19 auto policy = StaticScheduler(StaticScheduler::Policy::Fifo, 99);
20 // Set CPU affinity for main thread
21 if (auto ec = numapp::thisThread::Apply(policy); ec) {
22 std::cout << "Failed to apply policy: " << ec.message() << std::endl;
23 return 1;
24 }
25}
Static priority scheduler (real-time).
std::error_code Apply(CpuAffinity const &affinity) noexcept
Apply policy to calling thread.
bool NumaAvailable() noexcept
Query whether system has NUMA support.
Definition numa.hpp:35
Contains scheduler declarations.