job/queue: avoid noexcept termination in default_parallelism
This commit is contained in:
parent
f4ef1dc9a0
commit
39107bb62c
@ -3,13 +3,14 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 2018 Danny Robson <danny@nerdcruft.net>
|
||||
* Copyright 2018-2019 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#include "queue.hpp"
|
||||
|
||||
#include "../parse/value.hpp"
|
||||
#include "../scoped.hpp"
|
||||
#include "../log.hpp"
|
||||
|
||||
using cruft::job::queue;
|
||||
|
||||
@ -18,9 +19,13 @@ using cruft::job::queue;
|
||||
unsigned
|
||||
queue::default_parallelism (void) noexcept
|
||||
{
|
||||
try {
|
||||
if (auto var = getenv ("JOB_THREADS")) {
|
||||
return cruft::parse::from_string<unsigned> (var);
|
||||
}
|
||||
} catch (...) {
|
||||
LOG_ERROR ("Unable to parse JOB_THREADS. Using the default");
|
||||
}
|
||||
|
||||
return std::thread::hardware_concurrency ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user