RDKit
Open-source cheminformatics and machine learning.
RDThreads.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2015 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 #ifndef RDTHREADS_H_2015
12 #define RDTHREADS_H_2015
13 
14 #ifdef RDK_THREADSAFE_SSS
15 #include "RDGeneral/Invariant.h"
17 #include <boost/thread.hpp>
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 = boost::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
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
unsigned int getNumThreadsToUse(int target)
Definition: RDThreads.h:37
#define RDUNUSED_PARAM(x)
Definition: Invariant.h:190