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
58
class
Scheduler
:
public
Object
59
{
60
public
:
61
static
TypeId
GetTypeId
(
void
);
62
64
struct
EventKey
65
{
66
uint64_t
m_ts
;
67
uint32_t
m_uid
;
68
uint32_t
m_context
;
69
};
71
struct
Event
72
{
73
EventImpl
*
impl
;
74
EventKey
key
;
75
};
76
77
virtual
~Scheduler
() = 0;
78
82
virtual
void
Insert
(
const
Event
&ev) = 0;
86
virtual
bool
IsEmpty
(
void
)
const
= 0;
93
virtual
Event
PeekNext
(
void
)
const
= 0;
98
virtual
Event
RemoveNext
(
void
) = 0;
104
virtual
void
Remove
(
const
Event
&ev) = 0;
105
};
106
107
/* Note the invariants which this function must provide:
108
* - irreflexibility: f (x,x) is false)
109
* - antisymmetry: f(x,y) = !f(y,x)
110
* - transitivity: f(x,y) and f(y,z) => f(x,z)
111
*/
112
inline
bool
operator <
(
const
Scheduler::EventKey
&a,
const
Scheduler::EventKey
&b)
113
{
114
if
(a.
m_ts
< b.
m_ts
)
115
{
116
return
true
;
117
}
118
else
if
(a.
m_ts
== b.
m_ts
119
&& a.
m_uid
< b.
m_uid
)
120
{
121
return
true
;
122
}
123
else
124
{
125
return
false
;
126
}
127
}
128
inline
bool
operator !=
(
const
Scheduler::EventKey
&a,
const
Scheduler::EventKey
&b)
129
{
130
return
a.
m_uid
!= b.
m_uid
;
131
}
132
inline
bool
operator >
(
const
Scheduler::EventKey
&a,
const
Scheduler::EventKey
&b)
133
{
134
if
(a.
m_ts
> b.
m_ts
)
135
{
136
return
true
;
137
}
138
else
if
(a.
m_ts
== b.
m_ts
139
&& a.
m_uid
> b.
m_uid
)
140
{
141
return
true
;
142
}
143
else
144
{
145
return
false
;
146
}
147
}
148
149
150
151
inline
bool
operator <
(
const
Scheduler::Event
&a,
const
Scheduler::Event
&b)
152
{
153
return
a.
key
< b.
key
;
154
}
155
156
157
}
// namespace ns3
158
159
160
#endif
/* SCHEDULER_H */
ns3::Scheduler::PeekNext
virtual Event PeekNext(void) const =0
ns3::Scheduler::EventKey::m_ts
uint64_t m_ts
Definition:
scheduler.h:66
ns3::Scheduler::Event::impl
EventImpl * impl
Definition:
scheduler.h:73
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
Definition:
scheduler.h:74
ns3::Scheduler::EventKey::m_uid
uint32_t m_uid
Definition:
scheduler.h:67
ns3::Scheduler::Insert
virtual void Insert(const Event &ev)=0
ns3::Scheduler::GetTypeId
static TypeId GetTypeId(void)
Definition:
scheduler.cc:37
ns3::Scheduler
Maintain the event list.
Definition:
scheduler.h:58
ns3::operator<
bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator.
Definition:
int64x64-128.h:327
ns3::Scheduler::Event
Definition:
scheduler.h:71
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:1265
object.h
ns3::EventImpl
a simulation event
Definition:
event-impl.h:39
ns3::Scheduler::~Scheduler
virtual ~Scheduler()=0
Definition:
scheduler.cc:31
ns3::operator>
bool operator>(const int64x64_t &lhs, const int64x64_t &rhs)
Greater operator.
Definition:
int64x64-128.h:335
ns3::Scheduler::EventKey
Definition:
scheduler.h:64
ns3::Object
a base class which provides memory management and object aggregation
Definition:
object.h:64
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::Scheduler::EventKey::m_context
uint32_t m_context
Definition:
scheduler.h:68
src
core
model
scheduler.h
Generated on Wed Sep 17 2014 23:33:23 for ns-3 by
1.8.6