Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
hardware_concurrency.cpp
Go to the documentation of this file.
3#include <cstdlib>
4#include <iostream>
5#include <stdexcept>
6#include <string>
7
8#ifndef NO_MULTITHREADING
9#include <thread>
10#endif
11
12extern "C" {
13
14#ifdef NO_MULTITHREADING
16{
17 return 1;
18}
19#else
21{
22#ifndef __wasm__
23 try {
24#endif
25 static auto val = std::getenv("HARDWARE_CONCURRENCY");
26 static const uint32_t cores = val ? (uint32_t)std::stoul(val) : std::thread::hardware_concurrency();
27 return cores;
28#ifndef __wasm__
29 } catch (std::exception const&) {
30 throw std::runtime_error("HARDWARE_CONCURRENCY invalid.");
31 }
32#endif
33}
34#endif
35}
uint32_t env_hardware_concurrency()
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13