SUMO - Simulation of Urban MObility
MFXEventQue.h
Go to the documentation of this file.
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3
// Copyright (C) 2004-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
/****************************************************************************/
15
// missing_desc
16
/****************************************************************************/
17
#ifndef MFXEventQue_h
18
#define MFXEventQue_h
19
20
21
// ===========================================================================
22
// included modules
23
// ===========================================================================
24
#include <
config.h
>
25
26
#include <fx.h>
27
#include <list>
28
#include <cassert>
29
#include <
utils/foxtools/MFXMutex.h
>
30
31
template
<
class
T>
32
class
MFXEventQue
{
33
public
:
34
MFXEventQue
() { }
35
~MFXEventQue
() { }
36
37
T
top
() {
38
assert(
size
() != 0);
39
myMutex
.
lock
();
40
T ret =
myItems
.front();
41
myMutex
.
unlock
();
42
return
ret;
43
}
44
45
46
void
pop
() {
47
myMutex
.
lock
();
48
myItems
.erase(
myItems
.begin());
49
myMutex
.
unlock
();
50
}
51
52
void
add
(T what) {
53
myMutex
.
lock
();
54
myItems
.push_back(what);
55
myMutex
.
unlock
();
56
}
57
58
int
size
() {
59
myMutex
.
lock
();
60
const
int
ret = (int)
myItems
.size();
61
myMutex
.
unlock
();
62
return
ret;
63
}
64
65
bool
empty
() {
66
myMutex
.
lock
();
67
const
bool
ret =
myItems
.size() == 0;
68
myMutex
.
unlock
();
69
return
ret;
70
}
71
72
private
:
73
MFXMutex
myMutex
;
74
std::list<T>
myItems
;
75
};
76
77
78
#endif
79
80
/****************************************************************************/
81
MFXEventQue::size
int size()
Definition:
MFXEventQue.h:58
MFXEventQue::pop
void pop()
Definition:
MFXEventQue.h:46
MFXEventQue::empty
bool empty()
Definition:
MFXEventQue.h:65
MFXEventQue::add
void add(T what)
Definition:
MFXEventQue.h:52
config.h
MFXEventQue
Definition:
MFXEventQue.h:32
MFXEventQue::~MFXEventQue
~MFXEventQue()
Definition:
MFXEventQue.h:35
MFXEventQue::top
T top()
Definition:
MFXEventQue.h:37
MFXEventQue::myItems
std::list< T > myItems
Definition:
MFXEventQue.h:74
MFXMutex::unlock
void unlock()
release mutex lock
Definition:
MFXMutex.cpp:87
MFXMutex.h
MFXMutex
Definition:
MFXMutex.h:48
MFXMutex::lock
void lock()
lock mutex
Definition:
MFXMutex.cpp:77
MFXEventQue::myMutex
MFXMutex myMutex
Definition:
MFXEventQue.h:73
MFXEventQue::MFXEventQue
MFXEventQue()
Definition:
MFXEventQue.h:34
src
utils
foxtools
MFXEventQue.h
Generated on Sun Feb 3 2019 09:17:52 for SUMO - Simulation of Urban MObility by
1.8.13