42 .AddAttribute(
"Reverse",
43 "Store events in reverse chronological order",
75 Pop = [](
Bucket& bucket) ->
void { bucket.pop_back(); };
81 Pop = [](
Bucket& bucket) ->
void { bucket.pop_front(); };
103 std::cout <<
"Bucket Distribution ";
108 std::cout << std::endl;
130 for (
auto i =
m_buckets[bucket].begin(); i != end; ++i)
165 minEvent.
impl =
nullptr;
166 minEvent.
key.
m_ts = UINT64_MAX;
178 if (next.
key < minEvent.
key)
201 minKey.
m_ts = uint64_t(-int64_t(1));
217 if (next.
key < minKey)
260 for (
auto i =
m_buckets[bucket].begin(); i != end; ++i)
321 std::list<Scheduler::Event> samples;
328 for (
uint32_t i = 0; i < nSamples; i++)
333 for (
auto i = samples.begin(); i != samples.end(); ++i)
344 uint64_t totalSeparation = 0;
345 auto end = samples.end();
346 auto cur = samples.begin();
351 totalSeparation += next->key.m_ts - cur->key.m_ts;
355 uint64_t twiceAvg = totalSeparation / (nSamples - 1) * 2;
357 cur = samples.begin();
362 uint64_t diff = next->key.m_ts - cur->key.m_ts;
363 if (diff <= twiceAvg)
365 totalSeparation += diff;
371 totalSeparation *= 3;
372 totalSeparation = std::max(totalSeparation, (uint64_t)1);
373 return totalSeparation;
385 for (
uint32_t i = 0; i < oldNBuckets; i++)
387 auto end = oldBuckets[i].end();
388 for (
auto j = oldBuckets[i].begin(); j != end; ++j)
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
ns3::BooleanValue attribute value declarations.
ns3::CalendarScheduler class declaration.
AttributeValue implementation for Boolean.
a calendar queue event scheduler
bool m_reverse
Bucket ordering.
uint64_t CalculateNewWidth()
Compute the new bucket size, based on up to the first 25 entries.
uint32_t m_nBuckets
Number of buckets in the array.
bool(* Order)(const EventKey &newEvent, const EventKey &it)
Ordering function to identify the insertion point, according to m_reverse.
void PrintInfo()
Print the configuration and bucket size distribution.
uint32_t m_qSize
Number of events in queue.
Scheduler::Event &(* NextEvent)(Bucket &bucket)
Get the next event from the bucket, according to m_reverse.
void Remove(const Scheduler::Event &ev) override
Remove a specific event from the event list.
void Init(uint32_t nBuckets, uint64_t width, uint64_t startPrio)
Initialize the calendar queue.
void ResizeDown()
Halve the number of buckets if necessary.
uint32_t Hash(uint64_t key) const
Hash the dimensionless time to a bucket.
void Insert(const Scheduler::Event &ev) override
Insert a new Event in the schedule.
void DoInsert(const Scheduler::Event &ev)
Insert a new event in to the correct bucket.
uint64_t m_bucketTop
Priority at the top of the bucket from which last event was dequeued.
CalendarScheduler()
Constructor.
std::list< Scheduler::Event > Bucket
Calendar bucket type: a list of Events.
~CalendarScheduler() override
Destructor.
void DoResize(uint32_t newSize, uint64_t newWidth)
Resize the number of buckets and width.
Scheduler::Event PeekNext() const override
Get a pointer to the next event.
Scheduler::Event RemoveNext() override
Remove the earliest event from the event list.
Scheduler::Event DoRemoveNext()
Remove the earliest event.
uint32_t m_lastBucket
Bucket index from which the last event was dequeued.
void SetReverse(bool reverse)
Set the insertion order.
void Resize(uint32_t newSize)
Resize to a new number of buckets, with automatically computed width.
bool IsEmpty() const override
Test if the schedule is empty.
uint64_t m_lastPrio
The priority of the last event removed.
uint64_t m_width
Duration of a bucket, in dimensionless time units.
void ResizeUp()
Double the number of buckets if necessary.
Bucket * m_buckets
Array of buckets.
void(* Pop)(Bucket &)
Pop the next event from the bucket, according to m_reverse.
static TypeId GetTypeId()
Register this type.
a unique identifier for an interface.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
ns3::EventImpl declarations.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
EventKey key
Key for sorting and ordering Events.
EventImpl * impl
Pointer to the event implementation.
Structure for sorting and comparing Events.
uint32_t m_context
Event context.
uint64_t m_ts
Event time stamp.
uint32_t m_uid
Event unique id.
ns3::TypeId declaration; inline and template implementations.