RDKit
Open-source cheminformatics and machine learning.
RDThreads.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2015-2018 Greg Landrum
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 
11 #include <RDGeneral/export.h>
12 #ifndef RDTHREADS_H_2015
13 #define RDTHREADS_H_2015
14 
15 #include <RDGeneral/Invariant.h>
16 
17 #ifdef RDK_THREADSAFE_SSS
18 #include <thread>
19 
20 namespace RDKit {
21 inline unsigned int getNumThreadsToUse(int target) {
22  if (target >= 1) {
23  return static_cast<unsigned int>(target);
24  }
25  unsigned int res = std::thread::hardware_concurrency();
26  if (res > rdcast<unsigned int>(-target)) {
27  return res + target;
28  } else {
29  return 1;
30  }
31 }
32 }
33 
34 #else
35 
36 namespace RDKit {
37 inline unsigned int getNumThreadsToUse(int target) {
38  RDUNUSED_PARAM(target);
39  return 1;
40 }
41 }
42 #endif
43 
44 #endif
Std stuff.
Definition: Atom.h:30
unsigned int getNumThreadsToUse(int target)
Definition: RDThreads.h:37
#define RDUNUSED_PARAM(x)
Definition: Invariant.h:195