A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
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
155
class
Scheduler
:
public
Object
156
{
157
public
:
162
static
TypeId
GetTypeId
(
void
);
163
168
struct
EventKey
169
{
170
uint64_t
m_ts
;
171
uint32_t
m_uid
;
172
uint32_t
m_context
;
173
};
181
struct
Event
182
{
183
EventImpl
*
impl
;
184
EventKey
key
;
185
};
186
188
virtual
~Scheduler
() = 0;
189
195
virtual
void
Insert
(
const
Event
&ev) = 0;
201
virtual
bool
IsEmpty
(
void
)
const
= 0;
210
virtual
Event
PeekNext
(
void
)
const
= 0;
218
virtual
Event
RemoveNext
(
void
) = 0;
226
virtual
void
Remove
(
const
Event
&ev) = 0;
227
};
228
237
inline
bool
operator ==
(
const
Scheduler::EventKey
&a,
238
const
Scheduler::EventKey
&b)
239
{
240
return
a.
m_uid
== b.
m_uid
;
241
}
242
251
inline
bool
operator !=
(
const
Scheduler::EventKey
&a,
252
const
Scheduler::EventKey
&b)
253
{
254
return
a.
m_uid
!= b.
m_uid
;
255
}
256
270
inline
bool
operator <
(
const
Scheduler::EventKey
&a,
271
const
Scheduler::EventKey
&b)
272
{
273
if
(a.
m_ts
< b.
m_ts
)
274
{
275
return
true
;
276
}
277
else
if
(a.
m_ts
== b.
m_ts
278
&& a.
m_uid
< b.
m_uid
)
279
{
280
return
true
;
281
}
282
else
283
{
284
return
false
;
285
}
286
}
287
295
inline
bool
operator >
(
const
Scheduler::EventKey
&a,
296
const
Scheduler::EventKey
&b)
297
{
298
if
(a.
m_ts
> b.
m_ts
)
299
{
300
return
true
;
301
}
302
else
if
(a.
m_ts
== b.
m_ts
303
&& a.
m_uid
> b.
m_uid
)
304
{
305
return
true
;
306
}
307
else
308
{
309
return
false
;
310
}
311
}
312
320
inline
bool
operator ==
(
const
Scheduler::Event
&a,
321
const
Scheduler::Event
&b)
322
{
323
return
a.
key
== b.
key
;
324
}
325
333
inline
bool
operator !=
(
const
Scheduler::Event
&a,
334
const
Scheduler::Event
&b)
335
{
336
return
a.
key
!= b.
key
;
337
}
338
346
inline
bool
operator <
(
const
Scheduler::Event
&a,
347
const
Scheduler::Event
&b)
348
{
349
return
a.
key
< b.
key
;
350
}
351
359
inline
bool
operator >
(
const
Scheduler::Event
&a,
360
const
Scheduler::Event
&b)
361
{
362
return
a.
key
> b.
key
;
363
}
364
365
366
}
// namespace ns3
367
368
369
#endif
/* SCHEDULER_H */
ns3::EventImpl
A simulation event.
Definition:
event-impl.h:45
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:88
ns3::Scheduler
Maintain the event list.
Definition:
scheduler.h:156
ns3::Scheduler::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition:
scheduler.cc:43
ns3::Scheduler::Remove
virtual void Remove(const Event &ev)=0
Remove a specific event from the event list.
ns3::Scheduler::IsEmpty
virtual bool IsEmpty(void) const =0
Test if the schedule is empty.
ns3::Scheduler::PeekNext
virtual Event PeekNext(void) const =0
Get a pointer to the next event.
ns3::Scheduler::~Scheduler
virtual ~Scheduler()=0
Destructor.
Definition:
scheduler.cc:37
ns3::Scheduler::Insert
virtual void Insert(const Event &ev)=0
Insert a new Event in the schedule.
ns3::Scheduler::RemoveNext
virtual Event RemoveNext(void)=0
Remove the earliest event from the event list.
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::operator>
bool operator>(const int64x64_t &lhs, const int64x64_t &rhs)
Greater operator.
Definition:
int64x64-128.h:431
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator==
bool operator==(const EventId &a, const EventId &b)
Definition:
event-id.h:142
ns3::operator<
bool operator<(const EventId &a, const EventId &b)
Definition:
event-id.h:160
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:1606
object.h
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
ns3::Scheduler::Event
Scheduler event.
Definition:
scheduler.h:182
ns3::Scheduler::Event::key
EventKey key
Key for sorting and ordering Events.
Definition:
scheduler.h:184
ns3::Scheduler::Event::impl
EventImpl * impl
Pointer to the event implementation.
Definition:
scheduler.h:183
ns3::Scheduler::EventKey
Structure for sorting and comparing Events.
Definition:
scheduler.h:169
ns3::Scheduler::EventKey::m_context
uint32_t m_context
Event context.
Definition:
scheduler.h:172
ns3::Scheduler::EventKey::m_ts
uint64_t m_ts
Event time stamp.
Definition:
scheduler.h:170
ns3::Scheduler::EventKey::m_uid
uint32_t m_uid
Event unique id.
Definition:
scheduler.h:171
src
core
model
scheduler.h
Generated on Mon Sep 27 2021 10:49:45 for ns-3 by
1.9.1