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
list-scheduler.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#include "
list-scheduler.h
"
10
11
#include "
assert.h
"
12
#include "
event-impl.h
"
13
#include "
log.h
"
14
15
#include <string>
16
#include <utility>
17
18
/**
19
* \file
20
* \ingroup scheduler
21
* ns3::ListScheduler implementation.
22
*/
23
24
namespace
ns3
25
{
26
27
NS_LOG_COMPONENT_DEFINE
(
"ListScheduler"
);
28
29
NS_OBJECT_ENSURE_REGISTERED
(ListScheduler);
30
31
TypeId
32
ListScheduler::GetTypeId
()
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::ListScheduler"
)
35
.
SetParent
<
Scheduler
>()
36
.SetGroupName(
"Core"
)
37
.AddConstructor<
ListScheduler
>();
38
return
tid;
39
}
40
41
ListScheduler::ListScheduler
()
42
{
43
NS_LOG_FUNCTION
(
this
);
44
}
45
46
ListScheduler::~ListScheduler
()
47
{
48
}
49
50
void
51
ListScheduler::Insert
(
const
Event
& ev)
52
{
53
NS_LOG_FUNCTION
(
this
<< &ev);
54
for
(
auto
i =
m_events
.begin(); i !=
m_events
.end(); i++)
55
{
56
if
(ev.
key
< i->key)
57
{
58
m_events
.insert(i, ev);
59
return
;
60
}
61
}
62
m_events
.push_back(ev);
63
}
64
65
bool
66
ListScheduler::IsEmpty
()
const
67
{
68
NS_LOG_FUNCTION
(
this
);
69
return
m_events
.empty();
70
}
71
72
Scheduler::Event
73
ListScheduler::PeekNext
()
const
74
{
75
NS_LOG_FUNCTION
(
this
);
76
return
m_events
.front();
77
}
78
79
Scheduler::Event
80
ListScheduler::RemoveNext
()
81
{
82
NS_LOG_FUNCTION
(
this
);
83
Event
next =
m_events
.front();
84
m_events
.pop_front();
85
return
next;
86
}
87
88
void
89
ListScheduler::Remove
(
const
Event
& ev)
90
{
91
NS_LOG_FUNCTION
(
this
<< &ev);
92
for
(
auto
i =
m_events
.begin(); i !=
m_events
.end(); i++)
93
{
94
if
(i->key.m_uid == ev.
key
.
m_uid
)
95
{
96
NS_ASSERT
(ev.
impl
== i->impl);
97
m_events
.erase(i);
98
return
;
99
}
100
}
101
NS_ASSERT
(
false
);
102
}
103
104
}
// namespace ns3
assert.h
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
ns3::ListScheduler
a std::list event scheduler
Definition
list-scheduler.h:55
ns3::ListScheduler::~ListScheduler
~ListScheduler() override
Destructor.
Definition
list-scheduler.cc:46
ns3::ListScheduler::ListScheduler
ListScheduler()
Constructor.
Definition
list-scheduler.cc:41
ns3::ListScheduler::m_events
Events m_events
The event list.
Definition
list-scheduler.h:82
ns3::ListScheduler::RemoveNext
Scheduler::Event RemoveNext() override
Remove the earliest event from the event list.
Definition
list-scheduler.cc:80
ns3::ListScheduler::Remove
void Remove(const Scheduler::Event &ev) override
Remove a specific event from the event list.
Definition
list-scheduler.cc:89
ns3::ListScheduler::IsEmpty
bool IsEmpty() const override
Test if the schedule is empty.
Definition
list-scheduler.cc:66
ns3::ListScheduler::PeekNext
Scheduler::Event PeekNext() const override
Get a pointer to the next event.
Definition
list-scheduler.cc:73
ns3::ListScheduler::Insert
void Insert(const Scheduler::Event &ev) override
Insert a new Event in the schedule.
Definition
list-scheduler.cc:51
ns3::ListScheduler::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
list-scheduler.cc:32
ns3::Scheduler
Maintain the event list.
Definition
scheduler.h:146
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
event-impl.h
ns3::EventImpl declarations.
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition
assert.h:55
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
list-scheduler.h
ns3::ListScheduler declaration.
log.h
Debug message logging.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Scheduler::Event
Scheduler event.
Definition
scheduler.h:173
ns3::Scheduler::Event::key
EventKey key
Key for sorting and ordering Events.
Definition
scheduler.h:175
ns3::Scheduler::Event::impl
EventImpl * impl
Pointer to the event implementation.
Definition
scheduler.h:174
ns3::Scheduler::EventKey::m_uid
uint32_t m_uid
Event unique id.
Definition
scheduler.h:161
src
core
model
list-scheduler.cc
Generated on Wed Oct 9 2024 01:03:22 for ns-3 by
1.11.0