Skip to content

Commit c949169

Browse files
dmcdougalljwpeterson
authored andcommitted
Declare mutex only when threads are available
Make getpot disable mutexes when libmesh is absent
1 parent cf0ab34 commit c949169

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

include/base/getpot.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ extern "C" {
6868
#if !defined(GETPOT_DISABLE_MUTEX)
6969
#include "libmesh/threads.h"
7070
#define SCOPED_MUTEX libMesh::Threads::spin_mutex::scoped_lock lock(_getpot_mtx)
71+
#define GETPOT_MUTEX_DECLARE mutable libMesh::Threads::spin_mutex _getpot_mtx
7172
#else
7273
#define SCOPED_MUTEX
74+
#define GETPOT_MUTEX_DECLARE
7375
#endif
7476

7577
#define getpot_cerr libMesh::err
@@ -80,7 +82,9 @@ extern "C" {
8082
#else // USE_LIBMESH
8183

8284
// Currently threaded GetPot use is only supported via libMesh Threads
85+
#define GETPOT_DISABLE_MUTEX
8386
#define SCOPED_MUTEX
87+
#define GETPOT_MUTEX_DECLARE
8488

8589
#define getpot_cerr std::cerr
8690
#define getpot_error() throw std::runtime_error(std::string("GetPot Error"))
@@ -499,9 +503,7 @@ class GetPot
499503
* multiple threads at once, so we'll wrap access to
500504
* mutable objects in a mutex.
501505
*/
502-
#if !defined(GETPOT_DISABLE_MUTEX)
503-
mutable libMesh::Threads::spin_mutex _getpot_mtx;
504-
#endif
506+
GETPOT_MUTEX_DECLARE;
505507

506508
/**
507509
* some functions return a char pointer to a string created on the fly.

0 commit comments

Comments
 (0)