A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
scheduler.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
20
#ifndef SCHEDULER_H
21
#define SCHEDULER_H
22
23
#include "
object.h
"
24
25
#include <stdint.h>
26
35
namespace
ns3
36
{
37
38
class
EventImpl;
39
156
class
Scheduler
:
public
Object
157
{
158
public
:
163
static
TypeId
GetTypeId
();
164
169
struct
EventKey
170
{
171
uint64_t
m_ts
;
172
uint32_t
m_uid
;
173
uint32_t
m_context
;
174
};
175
183
struct
Event
184
{
185
EventImpl
*
impl
;
186
EventKey
key
;
187
};
188
190
~Scheduler
()
override
= 0;
191
197
virtual
void
Insert
(
const
Event
& ev) = 0;
203
virtual
bool
IsEmpty
()
const
= 0;
212
virtual
Event
PeekNext
()
const
= 0;
220
virtual
Event
RemoveNext
() = 0;
228
virtual
void
Remove
(
const
Event
& ev) = 0;
229
};
230
239
inline
bool
240
operator==
(
const
Scheduler::EventKey
& a,
const
Scheduler::EventKey
& b)
241
{
242
return
a.
m_uid
== b.
m_uid
;
243
}
244
253
inline
bool
254
operator!=
(
const
Scheduler::EventKey
& a,
const
Scheduler::EventKey
& b)
255
{
256
return
a.
m_uid
!= b.
m_uid
;
257
}
258
272
inline
bool
273
operator<
(
const
Scheduler::EventKey
& a,
const
Scheduler::EventKey
& b)
274
{
275
if
(a.
m_ts
< b.
m_ts
)
276
{
277
return
true
;
278
}
279
else
if
(a.
m_ts
== b.
m_ts
&& a.
m_uid
< b.
m_uid
)
280
{
281
return
true
;
282
}
283
else
284
{
285
return
false
;
286
}
287
}
288
296
inline
bool
297
operator>
(
const
Scheduler::EventKey
& a,
const
Scheduler::EventKey
& b)
298
{
299
if
(a.
m_ts
> b.
m_ts
)
300
{
301
return
true
;
302
}
303
else
if
(a.
m_ts
== b.
m_ts
&& a.
m_uid
> b.
m_uid
)
304
{
305
return
true
;
306
}
307
else
308
{
309
return
false
;
310
}
311
}
312
320
inline
bool
321
operator==
(
const
Scheduler::Event
& a,
const
Scheduler::Event
& b)
322
{
323
return
a.
key
== b.
key
;
324
}
325
333
inline
bool
334
operator!=
(
const
Scheduler::Event
& a,
const
Scheduler::Event
& b)
335
{
336
return
a.
key
!= b.
key
;
337
}
338
346
inline
bool
347
operator<
(
const
Scheduler::Event
& a,
const
Scheduler::Event
& b)
348
{
349
return
a.
key
< b.
key
;
350
}
351
359
inline
bool
360
operator>
(
const
Scheduler::Event
& a,
const
Scheduler::Event
& b)
361
{
362
return
a.
key
> b.
key
;
363
}
364
365
}
// namespace ns3
366
367
#endif
/* SCHEDULER_H */
ns3::EventImpl
A simulation event.
Definition:
event-impl.h:46
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::Scheduler
Maintain the event list.
Definition:
scheduler.h:157
ns3::Scheduler::~Scheduler
~Scheduler() override=0
Destructor.
Definition:
scheduler.cc:38
ns3::Scheduler::IsEmpty
virtual bool IsEmpty() const =0
Test if the schedule is empty.
ns3::Scheduler::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition:
scheduler.cc:44
ns3::Scheduler::Remove
virtual void Remove(const Event &ev)=0
Remove a specific event from the event list.
ns3::Scheduler::PeekNext
virtual Event PeekNext() const =0
Get a pointer to the next event.
ns3::Scheduler::Insert
virtual void Insert(const Event &ev)=0
Insert a new Event in the schedule.
ns3::Scheduler::RemoveNext
virtual Event RemoveNext()=0
Remove the earliest event from the event list.
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
uint32_t
ns3::operator>
bool operator>(const Length &left, const Length &right)
Check if left has a value greater than right.
Definition:
length.cc:421
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator!=
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition:
callback.h:676
ns3::operator==
bool operator==(const EventId &a, const EventId &b)
Definition:
event-id.h:157
ns3::operator<
bool operator<(const EventId &a, const EventId &b)
Definition:
event-id.h:170
object.h
ns3::Object class declaration, which is the root of the Object hierarchy and Aggregation.
ns3::Scheduler::Event
Scheduler event.
Definition:
scheduler.h:184
ns3::Scheduler::Event::key
EventKey key
Key for sorting and ordering Events.
Definition:
scheduler.h:186
ns3::Scheduler::Event::impl
EventImpl * impl
Pointer to the event implementation.
Definition:
scheduler.h:185
ns3::Scheduler::EventKey
Structure for sorting and comparing Events.
Definition:
scheduler.h:170
ns3::Scheduler::EventKey::m_context
uint32_t m_context
Event context.
Definition:
scheduler.h:173
ns3::Scheduler::EventKey::m_ts
uint64_t m_ts
Event time stamp.
Definition:
scheduler.h:171
ns3::Scheduler::EventKey::m_uid
uint32_t m_uid
Event unique id.
Definition:
scheduler.h:172
src
core
model
scheduler.h
Generated on Sun Jul 2 2023 18:21:32 for ns-3 by
1.9.6