SpatialOps
SpatialOpsTools.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2017 The University of Utah
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  */
22 
23 #ifndef SpatialOpsTools_h
24 #define SpatialOpsTools_h
25 
26 #include <spatialops/SpatialOpsConfigure.h>
27 
28 #ifdef ENABLE_THREADS
29 # include <spatialops/ThreadPool.h>
30 #endif
31 
36 namespace SpatialOps{
37 
46  template< typename T1, typename T2> struct IsSameType { enum{ result=0 }; };
47  template< typename T1 > struct IsSameType<T1,T1>{ enum{ result=1 }; };
48 
53  template< typename T1, typename T2 >
54  inline bool is_same_type(){
55  return bool( IsSameType<T1,T2>::result );
56  }
57 
58 #ifdef ENABLE_THREADS
59 
60  /* used within nebo to determine if thread parallelism should be used */
61  inline bool is_thread_parallel(){
63  }
64 
65  /* used within nebo to get current soft (active) thread count */
66  inline int get_soft_thread_count(){
68  }
69 
70  /* used by tests to change current soft (active) thread count at runtime */
71  inline int set_soft_thread_count( const int threadCount){
72  return ThreadPoolFIFO::resize_pool(threadCount);
73  }
74 
75  /* used within nebo to get current hard (max/total) thread count */
76  inline int get_hard_thread_count(){ return ThreadPoolFIFO::get_pool_capacity(); }
77 
78  /* used by tests to change current hard (max/total) thread count at runtime */
79  inline int set_hard_thread_count( const int threadCount){
80  return ThreadPoolFIFO::set_pool_capacity( threadCount );
81  }
82 
83 #endif // ENABLE_THREADS
84 
85 }
86 
87 #endif
88 
static int get_pool_capacity()
Definition: ThreadPool.cpp:215
bool is_same_type()
convenience function to obtain at runtime whether two types are equivalent or not ...
static int set_pool_capacity(const int threadCount)
set the maximum number of worker threads in the pool.
Definition: ThreadPool.cpp:212
static int resize_pool(const int threadCount)
set the number of active worker threads in the pool.
Definition: ThreadPool.cpp:205
Compares two types for equality.