MorphoGraphX  2.0-1-227
OMPGuard.hpp
Go to the documentation of this file.
1 //
2 // This is a class for guard objects using OpenMP
3 // It is adapted from the book
4 // "Pattern-Oriented Software Architecture".
5 // Taken from http://www.thinkingparallel.com - Michael Suess
6 //
7 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
8 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
9 //
10 // If you use MorphoGraphX in your work, please cite:
11 // http://dx.doi.org/10.7554/eLife.05864
12 //
13 // MorphoGraphX is free software, and is licensed under under the terms of the
14 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
15 //
16 #ifndef OMP_GUARD_HPP
17 #define OMP_GUARD_HPP
18 
19 #include <Config.hpp>
20 #include <omp.h>
21 
22 namespace mgx
23 {
30  class mgx_EXPORT OMPGuard
31  {
32  public:
34  OMPGuard (omp_lock_t &lock);
36  ~OMPGuard();
37 
38  private:
40  void acquire();
42  void release();
43 
44  omp_lock_t *_lock; // pointer to our lock
45  bool _owner; // is this object the owner of the lock?
46 
47  // Disallow copies or assignment
48  OMPGuard(const OMPGuard &);
49  void operator=(const OMPGuard &);
50  };
51 }
52 #endif
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::OMPGuard
This is a class for guard objects using OpenMP It is adapted from the book "Pattern-Oriented Software...
Definition: OMPGuard.hpp:30