SUMO - Simulation of Urban MObility
MFXMutex.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2007-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 //
18 /****************************************************************************/
19 
20 
21 #ifndef MFXMUTEX_H
22 #define MFXMUTEX_H
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <fx.h>
32 
33 #ifndef WIN32
34 // handle to a mutex
35 typedef void* FXThreadMutex;
36 #else
37 #define NOMINMAX
38 #include <windows.h>
39 #undef NOMINMAX
40 // handle to a mutex
41 typedef HANDLE FXThreadMutex;
42 #endif
43 
48 class MFXMutex : public AbstractMutex {
49 public:
51  MFXMutex();
52 
54  virtual ~MFXMutex();
55 
57  void lock();
58 
60  void unlock();
61 
63  inline FXbool locked() {
64  return lock_ ? TRUE : FALSE;
65  }
66 
68  inline FXuint lockCount() {
69  return lock_;
70  }
71 
72 protected:
74  FXuint lock_;
75 
76 private:
79 
80  // @brief invalidate copy constructor
81  MFXMutex(const MFXMutex&) = delete ;
82 
83  // @brief invalidate asignment operators
84  MFXMutex& operator=(const MFXMutex&) = delete ;
85 };
86 
87 #endif // FXMUTEX_H
FXuint lock_
lock count
Definition: MFXMutex.h:74
MFXMutex & operator=(const MFXMutex &)=delete
An abstract class for encapsulating mutex implementations.
Definition: AbstractMutex.h:42
FXThreadMutex mutexHandle
mutex handler
Definition: MFXMutex.h:78
FXuint lockCount()
return current lock value
Definition: MFXMutex.h:68
void * FXThreadMutex
Definition: MFXMutex.h:35
virtual ~MFXMutex()
destructor
Definition: MFXMutex.cpp:63
void unlock()
release mutex lock
Definition: MFXMutex.cpp:87
void lock()
lock mutex
Definition: MFXMutex.cpp:77
FXbool locked()
check if mutex is locked
Definition: MFXMutex.h:63
MFXMutex()
constructor
Definition: MFXMutex.cpp:41