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 #include <windows.h>
42 typedef HANDLE FXThreadMutex; // handle to a mutex
43 #endif
44 
45 
46 
47 
52 class MFXMutex : public AbstractMutex {
53 public:
55  MFXMutex();
56 
58  void lock();
59 
61  void unlock();
62 
64  virtual ~MFXMutex();
65 
66  inline FXbool locked() {
67  return lock_ ? TRUE : FALSE;
68  }
69 
70 protected:
71  FXuint lock_; // lock count
72 
73 private:
75 
76 private:
77  // dummy copy constructor and operator= to prevent copying
78  MFXMutex(const MFXMutex&);
79  MFXMutex& operator=(const MFXMutex&);
80 
81 };
82 
83 #endif // FXMUTEX_H