Skip to content

Commit fcefb95

Browse files
authored
Processor improvements and cleanup (#9)
* helper function to get all cores * cleanup includes
1 parent 1a83817 commit fcefb95

File tree

8 files changed

+18
-7
lines changed

8 files changed

+18
-7
lines changed

src/NUMANode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef NUMA_NODE_H
22
#define NUMA_NODE_H
33

4-
#include "TypePolicies.h"
54
#include "Core.h"
65

76
#include <set>

src/Pool.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
#include <type_traits>
55
#include <vector>
66
#include <array>
7-
#include <algorithm>
87
#include <functional>
98

109
#include "IndexHolder.h"
1110
#include "TypePolicies.h"
1211
#include "MutexIndexer.h"
13-
#include "ConcurrentIndexer.h"
1412
#include "PoolItem.h"
1513

1614
namespace dxpool {

src/Processor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@ using Processor = dxpool::ProcessorUnsupported;
1515
#endif
1616

1717

18+
static inline auto GetAllAvailableCores() -> std::set<Core> {
19+
Processor processor;
20+
return processor.FindAvailableCores();
21+
}
22+
1823
} // namespace dxpool
1924
#endif

src/ProcessorLinux.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef PROCESSOR_LINUX_H
22
#define PROCESSOR_LINUX_H
33

4-
#include <thread>
54
#include <pthread.h>
65
#include <sched.h>
76
#include <set>

src/ProcessorUnsupported.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ProcessorUnsupported final: public ProcessorOperator {
4545
*
4646
* @return
4747
*/
48-
auto SetThreadAffinity(const std::set<Core>& cores) const -> bool {
48+
auto SetThreadAffinity(const std::set<Core>& cores) const -> bool override {
4949
throw PlatformUnsupportedError("not implemented for this platform");
5050
}
5151

src/WorkerPool.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef WORKER_POOL_H
22
#define WORKER_POOL_H
33

4-
#include <string>
54
#include <memory>
65
#include <set>
76
#include <vector>

src/dxpool.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#ifndef DXPOOL_H
2+
#define DXPOOL_H
3+
14
#include "Pool.h"
25
#include "WorkerPool.h"
3-
#include "Processor.h"
6+
#include "Processor.h"
7+
8+
#endif //DXPOOL_H

test/ProcessorTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,10 @@ TEST_CASE("Processor and NUMA nodes") { // NOLINT(cppcoreguidelines-avoid-non-co
7575
REQUIRE(actualAffinity == desiredAffinity);
7676
}
7777

78+
79+
SECTION("Processor helper") {
80+
const auto allCores = GetAllAvailableCores();
81+
82+
REQUIRE_FALSE(allCores.empty());
83+
}
7884
}

0 commit comments

Comments
 (0)