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
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
35
namespace
ns3
{
36
37
class
EventImpl;
38
66
class
Scheduler
:
public
Object
67
{
68
public
:
69
static
TypeId
GetTypeId
(
void
);
70
75
struct
EventKey
76
{
77
uint64_t
m_ts
;
78
uint32_t
m_uid
;
79
uint32_t
m_context
;
80
};
88
struct
Event
89
{
90
EventImpl
*
impl
;
91
EventKey
key
;
92
};
93
94
virtual
~Scheduler
() = 0;
95
99
virtual
void
Insert
(
const
Event
&ev) = 0;
103
virtual
bool
IsEmpty
(
void
)
const
= 0;
110
virtual
Event
PeekNext
(
void
)
const
= 0;
115
virtual
Event
RemoveNext
(
void
) = 0;
121
virtual
void
Remove
(
const
Event
&ev) = 0;
122
};
123
124
/* Note the invariants which this function must provide:
125
* - irreflexibility: f (x,x) is false)
126
* - antisymmetry: f(x,y) = !f(y,x)
127
* - transitivity: f(x,y) and f(y,z) => f(x,z)
128
*/
129
inline
bool
operator <
(
const
Scheduler::EventKey
&a,
const
Scheduler::EventKey
&b)
130
{
131
if
(a.
m_ts
< b.
m_ts
)
132
{
133
return
true
;
134
}
135
else
if
(a.
m_ts
== b.
m_ts
136
&& a.
m_uid
< b.
m_uid
)
137
{
138
return
true
;
139
}
140
else
141
{
142
return
false
;
143
}
144
}
145
inline
bool
operator !=
(
const
Scheduler::EventKey
&a,
const
Scheduler::EventKey
&b)
146
{
147
return
a.
m_uid
!= b.
m_uid
;
148
}
149
inline
bool
operator >
(
const
Scheduler::EventKey
&a,
const
Scheduler::EventKey
&b)
150
{
151
if
(a.
m_ts
> b.
m_ts
)
152
{
153
return
true
;
154
}
155
else
if
(a.
m_ts
== b.
m_ts
156
&& a.
m_uid
> b.
m_uid
)
157
{
158
return
true
;
159
}
160
else
161
{
162
return
false
;
163
}
164
}
165
166
167
168
inline
bool
operator <
(
const
Scheduler::Event
&a,
const
Scheduler::Event
&b)
169
{
170
return
a.
key
< b.
key
;
171
}
172
173
174
}
// namespace ns3
175
176
177
#endif
/* SCHEDULER_H */
ns3::Scheduler::PeekNext
virtual Event PeekNext(void) const =0
ns3::Scheduler::EventKey::m_ts
uint64_t m_ts
Event time stamp.
Definition:
scheduler.h:77
ns3::Scheduler::Event::impl
EventImpl * impl
Pointer to the event implementation.
Definition:
scheduler.h:90
ns3::Scheduler::IsEmpty
virtual bool IsEmpty(void) const =0
ns3::Scheduler::RemoveNext
virtual Event RemoveNext(void)=0
This method cannot be invoked if the list is empty.
ns3::Scheduler::Remove
virtual void Remove(const Event &ev)=0
ns3::Scheduler::Event::key
EventKey key
Key for sorting and ordering Events.
Definition:
scheduler.h:91
ns3::Scheduler::EventKey::m_uid
uint32_t m_uid
Event unique id.
Definition:
scheduler.h:78
ns3::Scheduler::Insert
virtual void Insert(const Event &ev)=0
ns3::Scheduler::GetTypeId
static TypeId GetTypeId(void)
Definition:
scheduler.cc:43
ns3::Scheduler
Maintain the event list.
Definition:
scheduler.h:66
ns3::operator<
bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator.
Definition:
int64x64-128.h:356
ns3::Scheduler::Event
Scheduler event.
Definition:
scheduler.h:88
ns3::operator!=
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
Definition:
callback.h:1278
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
object.h
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
ns3::EventImpl
A simulation event.
Definition:
event-impl.h:44
ns3::Scheduler::~Scheduler
virtual ~Scheduler()=0
Definition:
scheduler.cc:37
ns3::operator>
bool operator>(const int64x64_t &lhs, const int64x64_t &rhs)
Greater operator.
Definition:
int64x64-128.h:364
ns3::Scheduler::EventKey
Structure for sorting and comparing Events.
Definition:
scheduler.h:75
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:87
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:57
ns3::Scheduler::EventKey::m_context
uint32_t m_context
Event context.
Definition:
scheduler.h:79
src
core
model
scheduler.h
Generated on Wed May 13 2015 14:59:12 for ns-3 by
1.8.9.1