A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
scheduler.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#ifndef SCHEDULER_H
22
#define SCHEDULER_H
23
24
#include <stdint.h>
25
#include "
object.h
"
26
27
namespace
ns3 {
28
29
class
EventImpl;
30
57
class
Scheduler
:
public
Object
58
{
59
public
:
60
static
TypeId
GetTypeId
(
void
);
61
63
struct
EventKey
64
{
65
uint64_t
m_ts
;
66
uint32_t
m_uid
;
67
uint32_t
m_context
;
68
};
70
struct
Event
71
{
72
EventImpl
*
impl
;
73
EventKey
key
;
74
};
75
76
virtual
~Scheduler
() = 0;
77
81
virtual
void
Insert
(
const
Event
&ev) = 0;
85
virtual
bool
IsEmpty
(
void
)
const
= 0;
92
virtual
Event
PeekNext
(
void
)
const
= 0;
97
virtual
Event
RemoveNext
(
void
) = 0;
103
virtual
void
Remove
(
const
Event
&ev) = 0;
104
};
105
106
/* Note the invariants which this function must provide:
107
* - irreflexibility: f (x,x) is false)
108
* - antisymmetry: f(x,y) = !f(y,x)
109
* - transitivity: f(x,y) and f(y,z) => f(x,z)
110
*/
111
inline
bool
operator <
(
const
Scheduler::EventKey
&a,
const
Scheduler::EventKey
&b)
112
{
113
if
(a.
m_ts
< b.
m_ts
)
114
{
115
return
true
;
116
}
117
else
if
(a.
m_ts
== b.
m_ts
118
&& a.
m_uid
< b.
m_uid
)
119
{
120
return
true
;
121
}
122
else
123
{
124
return
false
;
125
}
126
}
127
inline
bool
operator !=
(
const
Scheduler::EventKey
&a,
const
Scheduler::EventKey
&b)
128
{
129
return
a.
m_uid
!= b.
m_uid
;
130
}
131
inline
bool
operator >
(
const
Scheduler::EventKey
&a,
const
Scheduler::EventKey
&b)
132
{
133
if
(a.
m_ts
> b.
m_ts
)
134
{
135
return
true
;
136
}
137
else
if
(a.
m_ts
== b.
m_ts
138
&& a.
m_uid
> b.
m_uid
)
139
{
140
return
true
;
141
}
142
else
143
{
144
return
false
;
145
}
146
}
147
148
149
150
inline
bool
operator <
(
const
Scheduler::Event
&a,
const
Scheduler::Event
&b)
151
{
152
return
a.
key
< b.
key
;
153
}
154
155
156
}
// namespace ns3
157
158
159
#endif
/* SCHEDULER_H */
src
core
model
scheduler.h
Generated on Fri Aug 30 2013 01:42:47 for ns-3 by
1.8.1.2