SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RecursiveMutex.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 
30 
31 ///
32 ///@file Barrier
33 ///@brief Barrier synchronization primitive
34 ///
35 ///@author Steve Parker
36 /// Department of Computer Science
37 /// University of Utah
38 ///@date June 1997
39 ///
40 
41 #ifndef Core_Thread_RecursiveMutex_h
42 #define Core_Thread_RecursiveMutex_h
43 
45 
47 
48 namespace SCIRun {
49 
50 class RecursiveMutex_private;
51 /**************************************
52 
53 @class
54  RecursiveMutex
55 
56  KEYWORDS
57  Thread
58 
59 @details
60  Provides a recursive <b>Mut</b>ual <b>Ex</b>clusion primitive. Atomic
61  <b>lock()</b> and <b>unlock()</b> will lock and unlock the mutex.
62  Nested calls to <b>lock()</b> by the same thread are acceptable,
63  but must be matched with calls to <b>unlock()</b>. This class
64  may be less efficient that the <b>Mutex</b> class, and should not
65  be used unless the recursive lock feature is really required.
66 
67 ****************************************/
69 public:
70  //////////
71  /// Create the Mutex. The Mutex is allocated in the unlocked
72  /// state. <i>name</i> should be a static string which describe
73  /// the primitive for debugging purposes.
74  explicit RecursiveMutex(const char* name);
75 
76  //////////
77  /// Destroy the Mutex. Destroying a Mutex in the locked state
78  /// has undefined results.
79  ~RecursiveMutex();
80 
81  //////////
82  /// Acquire the Mutex. This method will block until the Mutex
83  /// is acquired.
84  void lock();
85 
86  //////////
87  /// Attempt to acquire the Mutex without blocking. Returns
88  /// true if the mutex was available and actually acquired.
89  bool tryLock();
90 
91  //////////
92  /// Release the Mutex, unblocking any other threads that are
93  /// blocked waiting for the Mutex.
94  void unlock();
95 
96  friend class ConditionVariable;
97 private:
98  const char* name_;
100 
101  // Cannot copy them
103  RecursiveMutex& operator=(const RecursiveMutex&);
104 };
105 
106 } // End namespace SCIRun
107 
108 #endif
109 
110 
Definition: RecursiveMutex.h:68
#define SCISHARE
Definition: share.h:39
Definition: ConditionVariable.h:80
const char * name[]
Definition: BoostGraphExampleTests.cc:87
Definition: Thread_pthreads.cc:947