/usr/include/ns3.26/ns3/scheduler.h is in libns3-dev 3.26+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#ifndef SCHEDULER_H
#define SCHEDULER_H
#include <stdint.h>
#include "object.h"
/**
* \file
* \ingroup scheduler
* \ingroup events
* ns3::Scheduler abstract base class, ns3::Scheduler::Event and
* ns3::Scheduler::EventKey declarations.
*/
namespace ns3 {
class EventImpl;
/**
* \ingroup core
* \defgroup scheduler Scheduler and Events
* \brief Manage the event list by creating and scheduling events.
*/
/**
* \ingroup scheduler
* \defgroup events Events
*/
/**
* \ingroup scheduler
* \brief Maintain the event list
*
* This base class specifies the interface used to maintain the
* event list. If you want to provide a new event list scheduler,
* you need to create a subclass of this base class and implement
* all the pure virtual methods defined here.
*
* The only tricky aspect of this API is the memory management of
* the EventImpl pointer which is a member of the Event data structure.
* The lifetime of this pointer is assumed to always be longer than
* the lifetime of the Scheduler class which means that the caller
* is responsible for ensuring that this invariant holds through
* calling EventId::Ref and SimpleRefCount::Unref at the right time.
* Typically, EventId::Ref is called before Insert and SimpleRefCount::Unref is called
* after a call to one of the Remove methods.
*/
class Scheduler : public Object
{
public:
/**
* Register this type.
* \return The object TypeId.
*/
static TypeId GetTypeId (void);
/**
* \ingroup events
* Structure for sorting and comparing Events.
*/
struct EventKey
{
uint64_t m_ts; /**< Event time stamp. */
uint32_t m_uid; /**< Event unique id. */
uint32_t m_context; /**< Event context. */
};
/**
* \ingroup events
* Scheduler event.
*
* An Event consists of an EventKey, used for maintaining the schedule,
* and an EventImpl which is the actual implementation.
*/
struct Event
{
EventImpl *impl; /**< Pointer to the event implementation. */
EventKey key; /**< Key for sorting and ordering Events. */
};
/** Destructor. */
virtual ~Scheduler () = 0;
/**
* Insert a new Event in the schedule.
*
* \param [in] ev Event to store in the event list
*/
virtual void Insert (const Event &ev) = 0;
/**
* Test if the schedule is empty.
*
* \returns \c true if the event list is empty and \c false otherwise.
*/
virtual bool IsEmpty (void) const = 0;
/**
* Get a pointer to the next event.
*
* This method cannot be invoked if the list is empty.
*
* \returns A pointer to the next earliest event. The caller
* takes ownership of the returned pointer.
*/
virtual Event PeekNext (void) const = 0;
/**
* Remove the earliest event from the event list.
*
* This method cannot be invoked if the list is empty.
*
* \return The Event.
*/
virtual Event RemoveNext (void) = 0;
/**
* Remove a specific event from the event list.
*
* This method cannot be invoked if the list is empty.
*
* \param [in] ev The event to remove
*/
virtual void Remove (const Event &ev) = 0;
};
/**
* \ingroup Events
* Compare (less than) two events by EventKey.
*
* Note the invariants which this function must provide:
* - irreflexibility: f (x,x) is false
* - antisymmetry: f(x,y) = !f(y,x)
* - transitivity: f(x,y) and f(y,z) => f(x,z)
*
* \param [in] a The first event.
* \param [in] b The second event.
* \returns \c true if \c a < \c b
*/
inline bool operator < (const Scheduler::EventKey &a,
const Scheduler::EventKey &b)
{
if (a.m_ts < b.m_ts)
{
return true;
}
else if (a.m_ts == b.m_ts
&& a.m_uid < b.m_uid)
{
return true;
}
else
{
return false;
}
}
/**
* \ingroup Events
* Compare (not equal) two events by EventKey.
*
* \param [in] a The first event.
* \param [in] b The second event.
* \returns \c true if \c a != \c b
*/
inline bool operator != (const Scheduler::EventKey &a,
const Scheduler::EventKey &b)
{
return a.m_uid != b.m_uid;
}
/**
* Compare (greater than) two events by EventKey.
*
* \param [in] a The first event.
* \param [in] b The second event.
* \returns \c true if \c a > \c b
*/
inline bool operator > (const Scheduler::EventKey &a,
const Scheduler::EventKey &b)
{
if (a.m_ts > b.m_ts)
{
return true;
}
else if (a.m_ts == b.m_ts
&& a.m_uid > b.m_uid)
{
return true;
}
else
{
return false;
}
}
/**
* Compare (less than) two events by Event.
*
* \param [in] a The first event.
* \param [in] b The second event.
* \returns \c true if \c a < \c b
*/
inline bool operator < (const Scheduler::Event &a,
const Scheduler::Event &b)
{
return a.key < b.key;
}
} // namespace ns3
#endif /* SCHEDULER_H */
|