threads_none.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 #ifndef LIBMESH_THREADS_NONE_H
20 #define LIBMESH_THREADS_NONE_H
21 
22 // Do not try to #include this header directly, it is designed to be
23 // #included directly by threads.h
24 #ifndef LIBMESH_SQUASH_HEADER_WARNING
25 # warning "This file is designed to be included through libmesh/threads.h"
26 #else
27 
28 #if !defined(LIBMESH_HAVE_TBB_API) && !defined(LIBMESH_HAVE_PTHREAD)
29 
30 // Thread-Local-Storage macros
31 #define LIBMESH_TLS_TYPE(type) type
32 #define LIBMESH_TLS_REF(value) (value)
33 
34 namespace libMesh
35 {
36 
37 namespace Threads
38 {
39 
44 
49 {
50 public:
51  static const int automatic = -1;
52  explicit task_scheduler_init (int = automatic) {}
53  void initialize (int = automatic) {}
54  void terminate () {}
55 };
56 
57 
58 
63 class split {};
64 
65 
66 
71 template <typename Range, typename Body>
72 inline
73 void parallel_for (const Range & range, const Body & body)
74 {
76  body(range);
77 }
78 
79 
80 
85 template <typename Range, typename Body, typename Partitioner>
86 inline
87 void parallel_for (const Range & range, const Body & body, const Partitioner &)
88 {
90  body(range);
91 }
92 
93 
94 
99 template <typename Range, typename Body>
100 inline
101 void parallel_reduce (const Range & range, Body & body)
102 {
104  body(range);
105 }
106 
107 
108 
113 template <typename Range, typename Body, typename Partitioner>
114 inline
115 void parallel_reduce (const Range & range, Body & body, const Partitioner &)
116 {
118  body(range);
119 }
120 
121 
122 
128 {
129 public:
131  void lock () {}
132  void unlock () {}
133 
135  {
136  public:
138  explicit scoped_lock ( spin_mutex & ) {}
139  void acquire ( spin_mutex & ) {}
140  void release () {}
141  };
142 };
143 
144 
145 
151 {
152 public:
154 
156  {
157  public:
159  explicit scoped_lock ( recursive_mutex & ) {}
160  void acquire ( recursive_mutex & ) {}
161  void release () {}
162  };
163 };
164 
165 
166 
171 template <typename T>
172 class atomic
173 {
174 public:
175  atomic () : _val(0) {}
176  operator T & () { return _val; }
177 private:
178  T _val;
179 };
180 
181 } // namespace Threads
182 
183 } // namespace libMesh
184 
185 #endif // !defined(LIBMESH_HAVE_TBB_API) && !defined(LIBMESH_HAVE_PTHREAD)
186 
187 #endif // LIBMESH_SQUASH_HEADER_WARNING
188 
189 #endif // LIBMESH_THREADS_NONE_H
NonConcurrentThread Thread
Definition: threads_none.h:43
void parallel_for(const Range &range, const Body &body)
Definition: threads_none.h:73
bool in_threads
Definition: threads.C:31
Base class for all concrete Partitioner instantiations.
Definition: partitioner.h:50
void parallel_reduce(const Range &range, Body &body)
Definition: threads_none.h:101