SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MFXMutex.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * Mutal exclusion object (required for threads) *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 ********************************************************************************/
22 #ifndef MFXMUTEX_H
23 #define MFXMUTEX_H
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <fx.h>
37 
38 #ifndef WIN32
39 typedef void* FXThreadMutex; // handle to a mutex
40 #else
41 #define NOMINMAX
42 #include <windows.h>
43 #undef NOMINMAX
44 typedef HANDLE FXThreadMutex; // handle to a mutex
45 #endif
46 
47 
48 
49 
54 class MFXMutex : public AbstractMutex {
55 public:
57  MFXMutex();
58 
60  void lock();
61 
63  void unlock();
64 
66  virtual ~MFXMutex();
67 
68  inline FXbool locked() {
69  return lock_ ? TRUE : FALSE;
70  }
71 
72 protected:
73  FXuint lock_; // lock count
74 
75 private:
77 
78 private:
79  // dummy copy constructor and operator= to prevent copying
80  MFXMutex(const MFXMutex&);
81  MFXMutex& operator=(const MFXMutex&);
82 
83 };
84 
85 #endif // FXMUTEX_H
FXuint lock_
Definition: MFXMutex.h:73
MFXMutex & operator=(const MFXMutex &)
An abstract class for encapsulating mutex implementations.
Definition: AbstractMutex.h:49
FXThreadMutex mutexHandle
Definition: MFXMutex.h:76
void * FXThreadMutex
Definition: MFXMutex.h:39
virtual ~MFXMutex()
dtor
Definition: MFXMutex.cpp:70
void unlock()
release mutex lock
Definition: MFXMutex.cpp:94
void lock()
lock mutex
Definition: MFXMutex.cpp:84
FXbool locked()
Definition: MFXMutex.h:68
MFXMutex()
create me a mutex :-)
Definition: MFXMutex.cpp:48