forked from khizmax/libcds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
topology_linux.cpp
54 lines (45 loc) · 1.39 KB
/
topology_linux.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2006-2018 Maxim Khizhinsky
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <cds/os/topology.h>
#if CDS_OS_TYPE == CDS_OS_LINUX
#include <thread>
/*
#include <unistd.h>
#include <fstream>
*/
namespace cds { namespace OS { inline namespace Linux {
unsigned int topology::s_nProcessorCount = 0;
void topology::init()
{
s_nProcessorCount = std::thread::hardware_concurrency();
/*
long n = ::sysconf( _SC_NPROCESSORS_ONLN );
if ( n > 0 )
s_nProcessorCount = static_cast<unsigned>( n );
else {
try {
std::ifstream cpuinfo("/proc/cpuinfo");
std::string line;
unsigned int nProcCount = 0;
while ( !cpuinfo.eof()) {
std::getline(cpuinfo,line);
if (!line.size())
continue;
if ( line.find( "processor" ) !=0 )
continue;
++nProcCount;
}
s_nProcessorCount = nProcCount;
}
catch ( std::exception& ex ) {
s_nProcessorCount = 1;
}
}
*/
}
void topology::fini()
{}
}}} // namespace cds::OS::Linux
#endif // #if CDS_OS_TYPE == CDS_OS_LINUX