libMesh
threads_spin_mutex_forward.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2026 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 #ifndef LIBMESH_THREADS_SPIN_MUTEX_FORWARD_H
19 #define LIBMESH_THREADS_SPIN_MUTEX_FORWARD_H
20 
21 #include "libmesh/libmesh_config.h"
22 
23 // Lightweight forward declaration of Threads::spin_mutex for headers that
24 // need the type without including the full threads.h.
25 //
26 // In the TBB backend spin_mutex is a typedef for tbb::spin_mutex, which is
27 // itself introduced into namespace tbb via an inline-namespace using-alias
28 // (not a direct class definition). A plain "class spin_mutex" forward
29 // declaration in namespace tbb would therefore conflict with that alias, so
30 // we must include tbb/spin_mutex.h to make the type complete and then
31 // re-declare the typedef. For the pthreads and serial backends spin_mutex
32 // is a proper class and a forward declaration suffices.
33 
34 #ifdef LIBMESH_HAVE_TBB_API
35 
36 # include "libmesh/ignore_warnings.h"
37 # include "tbb/spin_mutex.h"
38 # include "libmesh/restore_warnings.h"
39 
40 namespace libMesh
41 {
42 namespace Threads
43 {
45 } // namespace Threads
46 } // namespace libMesh
47 
48 #else
49 
50 namespace libMesh
51 {
52 namespace Threads
53 {
54 class spin_mutex;
55 } // namespace Threads
56 } // namespace libMesh
57 
58 #endif // LIBMESH_HAVE_TBB_API
59 
60 #endif // LIBMESH_THREADS_SPIN_MUTEX_FORWARD_H
The libMesh namespace provides an interface to certain functionality in the library.
tbb::spin_mutex spin_mutex
Spin mutex.