]> git.ipfire.org Git - thirdparty/squid.git/blob - src/CpuAffinitySet.h
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / CpuAffinitySet.h
1 /*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_CPU_AFFINITY_SET_H
10 #define SQUID_CPU_AFFINITY_SET_H
11
12 #include "compat/cpu.h"
13
14 /// cpu affinity management for a single process
15 class CpuAffinitySet
16 {
17 public:
18 CpuAffinitySet();
19
20 /// set CPU affinity for this process
21 void apply();
22
23 /// undo CPU affinity changes for this process
24 void undo();
25
26 /// whether apply() was called and was not undone
27 bool applied();
28
29 /// set CPU affinity mask
30 void set(const cpu_set_t &aCpuSet);
31
32 private:
33 cpu_set_t theCpuSet; ///< configured CPU affinity for this process
34 cpu_set_t theOrigCpuSet; ///< CPU affinity for this process before apply()
35 };
36
37 #endif // SQUID_CPU_AFFINITY_SET_H
38