SUMO - Simulation of Urban MObility
AbstractMutex.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
16 // An abstract class for encapsulating mutex implementations
17 /****************************************************************************/
18 #ifndef AbstractMutex_h
19 #define AbstractMutex_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 
28 // ===========================================================================
29 // class definitions
30 // ===========================================================================
43 public:
46 
48  virtual ~AbstractMutex() { }
49 
51  virtual void lock() = 0;
52 
54  virtual void unlock() = 0;
55 
59  class ScopedLocker {
60  public:
67  myLock.lock();
68  }
69 
70 
75  myLock.unlock();
76  }
77 
78  private:
81 
82  private:
84  ScopedLocker(const ScopedLocker&);
85 
88  };
89 
90 
91 
92 };
93 
94 
95 #endif
96 
97 /****************************************************************************/
98 
An abstract class for encapsulating mutex implementations.
Definition: AbstractMutex.h:42
AbstractMutex & myLock
The mutex to lock.
Definition: AbstractMutex.h:80
virtual ~AbstractMutex()
Destructor.
Definition: AbstractMutex.h:48
virtual void lock()=0
Locks the mutex.
ScopedLocker & operator=(const ScopedLocker &)
Invalidated assignment operator.
A mutex encapsulator which locks/unlocks the given mutex on construction/destruction, respectively.
Definition: AbstractMutex.h:59
virtual void unlock()=0
Unlocks the mutex.
~ScopedLocker()
Destructor Unlocks the mutex.
Definition: AbstractMutex.h:74
AbstractMutex()
Constructor.
Definition: AbstractMutex.h:45
ScopedLocker(AbstractMutex &lock)
Constructor.
Definition: AbstractMutex.h:66