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-2017 German Aerospace Center (DLR) and others.
4
/****************************************************************************/
5
//
6
// This program and the accompanying materials
7
// are made available under the terms of the Eclipse Public License v2.0
8
// which accompanies this distribution, and is available at
9
// http://www.eclipse.org/legal/epl-v20.html
10
//
11
/****************************************************************************/
17
// missing_desc
18
/****************************************************************************/
19
#ifndef MFXEventQue_h
20
#define MFXEventQue_h
21
22
23
// ===========================================================================
24
// included modules
25
// ===========================================================================
26
#ifdef _MSC_VER
27
#include <
windows_config.h
>
28
#else
29
#include <
config.h
>
30
#endif
31
32
#include <fx.h>
33
#include <list>
34
#include <cassert>
35
#include <
utils/foxtools/MFXMutex.h
>
36
37
template
<
class
T>
38
class
MFXEventQue
{
39
public
:
40
MFXEventQue
() { }
41
~MFXEventQue
() { }
42
43
T
top
() {
44
assert(
size
() != 0);
45
myMutex
.
lock
();
46
T ret =
myItems
.front();
47
myMutex
.
unlock
();
48
return
ret;
49
}
50
51
52
void
pop
() {
53
myMutex
.
lock
();
54
myItems
.erase(
myItems
.begin());
55
myMutex
.
unlock
();
56
}
57
58
void
add
(T what) {
59
myMutex
.
lock
();
60
myItems
.push_back(what);
61
myMutex
.
unlock
();
62
}
63
64
int
size
() {
65
myMutex
.
lock
();
66
const
int
ret = (int)
myItems
.size();
67
myMutex
.
unlock
();
68
return
ret;
69
}
70
71
bool
empty
() {
72
myMutex
.
lock
();
73
const
bool
ret =
myItems
.size() == 0;
74
myMutex
.
unlock
();
75
return
ret;
76
}
77
78
private
:
79
MFXMutex
myMutex
;
80
std::list<T>
myItems
;
81
};
82
83
84
#endif
85
86
/****************************************************************************/
87
MFXEventQue::size
int size()
Definition:
MFXEventQue.h:64
MFXEventQue::pop
void pop()
Definition:
MFXEventQue.h:52
MFXEventQue::empty
bool empty()
Definition:
MFXEventQue.h:71
windows_config.h
MFXEventQue::add
void add(T what)
Definition:
MFXEventQue.h:58
config.h
MFXEventQue
Definition:
MFXEventQue.h:38
MFXEventQue::~MFXEventQue
~MFXEventQue()
Definition:
MFXEventQue.h:41
MFXEventQue::top
T top()
Definition:
MFXEventQue.h:43
MFXEventQue::myItems
std::list< T > myItems
Definition:
MFXEventQue.h:80
MFXMutex::unlock
void unlock()
release mutex lock
Definition:
MFXMutex.cpp:93
MFXMutex.h
MFXMutex
Definition:
MFXMutex.h:55
MFXMutex::lock
void lock()
lock mutex
Definition:
MFXMutex.cpp:83
MFXEventQue::myMutex
MFXMutex myMutex
Definition:
MFXEventQue.h:79
MFXEventQue::MFXEventQue
MFXEventQue()
Definition:
MFXEventQue.h:40
src
utils
foxtools
MFXEventQue.h
Generated on Sat May 12 2018 19:00:22 for SUMO - Simulation of Urban MObility by
1.8.13