NUMA++ 0.12.0
Loading...
Searching...
No Matches
memlockExample1.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/memory.hpp>
10
11int main() {
12 using numapp::operator|;
14 if (!numapp::NumaAvailable()) {
15 std::cout << "NUMA not available";
16 return -1;
17 }
18
19 // Lock current and future mappings
20 if (auto ec = numapp::MemLockAll(LockAllFlag::Current | LockAllFlag::Future); ec) {
21 std::cerr << "Failed to lock memory!" << std::endl;
22 return -1;
23 }
24}
LockAllFlag
Flags that are combined to modify behaviour of MemLockAll().
Definition memory.hpp:148
std::error_code MemLockAll(LockAllFlag flags) noexcept
Lock all memory pages as specified by provided flags.
Definition memory.cpp:74
bool NumaAvailable() noexcept
Query whether system has NUMA support.
Definition numa.hpp:35
Contains memory function declarations.