| 407 | |
| 408 | |
| 409 | int System::get_cores() const |
| 410 | { |
| 411 | int cores = 0; |
| 412 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 413 | SYSTEM_INFO sysinfo; |
| 414 | GetSystemInfo(&sysinfo); |
| 415 | cores = static_cast<int>(sysinfo.dwNumberOfProcessors); |
| 416 | #elif defined(__APPLE__) || defined(__linux__) |
| 417 | cores = sysconf(_SC_NPROCESSORS_ONLN); |
| 418 | #endif |
| 419 | |
| 420 | // TODO Think about thread::hardware_concurrency(). |
| 421 | // This should be standard in C++11. |
| 422 | |
| 423 | return cores; |
| 424 | } |
| 425 | |
| 426 | |
| 427 | string System::get_threading(int& thr) const |