SheafSystem  0.0.0.0
thread_mutex.h
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Interface for class THREAD_MUTEX
19 
20 #ifndef THREAD_MUTEX_H
21 #define THREAD_MUTEX_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifdef _PTHREADS
28 #include "SheafSystem/pthread.h"
29 
30 namespace sheaf
31 {
32 
36 class SHEAF_DLL_SPEC thread_mutex
37 {
38 
39 private:
40 
41  // data:
42 
43  pthread_mutex_t pthread_mutex;
44  pthread_mutexattr_t pthread_mutexattr;
45 
46 public:
47 
48  // queries:
49 
53  pthread_mutex_t *get_pthread_mutex();
54 
58  bool invariant() const;
59 
60  // actions:
61 
65  void lock()
66  ;
67 
71  bool trylock();
72 
76  void unlock();
77 
78  // constructors:
79 
83  thread_mutex();
84 
88  ~thread_mutex();
89 };
90 
91 } // namespace sheaf
92 
93 #endif // _PTHREADS
94 
95 #endif // ifndef THREAD_MUTEX_H
Namespace for the sheaves component of the sheaf system.