49 .SetGroupName (
"Core")
51 .AddAttribute (
"Reverse",
52 "Store events in reverse chronological order",
83 return bucket.back ();
98 return bucket.front ();
129 std::cout <<
"Bucket Distribution ";
132 std::cout <<
m_buckets[i].size () <<
" ";
134 std::cout << std::endl;
154 Bucket::iterator end =
m_buckets[bucket].end ();
155 for (Bucket::iterator i =
m_buckets[bucket].begin (); i != end; ++i)
189 minEvent.
key.
m_ts = UINT64_MAX;
201 if (next.
key < minEvent.
key)
222 int32_t minBucket = -1;
225 minKey.
m_ts = uint64_t (-int64_t (1));
241 if (next.
key < minKey)
285 Bucket::iterator end =
m_buckets[bucket].end ();
286 for (Bucket::iterator i =
m_buckets[bucket].begin (); i != end; ++i)
347 std::list<Scheduler::Event> samples;
354 for (uint32_t i = 0; i < nSamples; i++)
359 for (std::list<Scheduler::Event>::const_iterator i = samples.begin ();
360 i != samples.end (); ++i)
371 uint64_t totalSeparation = 0;
372 std::list<Scheduler::Event>::const_iterator end = samples.end ();
373 std::list<Scheduler::Event>::const_iterator cur = samples.begin ();
374 std::list<Scheduler::Event>::const_iterator next = cur;
378 totalSeparation += next->key.m_ts - cur->key.m_ts;
382 uint64_t twiceAvg = totalSeparation / (nSamples - 1) * 2;
384 cur = samples.begin ();
389 uint64_t diff = next->key.m_ts - cur->key.m_ts;
390 if (diff <= twiceAvg)
392 totalSeparation += diff;
398 totalSeparation *= 3;
399 totalSeparation =
std::max (totalSeparation, (uint64_t)1);
400 return totalSeparation;
411 for (uint32_t i = 0; i < oldNBuckets; i++)
413 Bucket::iterator end = oldBuckets[i].end ();
414 for (Bucket::iterator j = oldBuckets[i].begin (); j != end; ++j)
419 delete [] oldBuckets;
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.
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.
uint32_t m_qSize
Number of events in queue.
uint64_t CalculateNewWidth(void)
Compute the new bucket size, based on up to the first 25 entries.
virtual bool IsEmpty(void) const
Test if the schedule is empty.
void Init(uint32_t nBuckets, uint64_t width, uint64_t startPrio)
Initialize the calendar queue.
Scheduler::Event DoRemoveNext(void)
Remove the earliest event.
uint32_t Hash(uint64_t key) const
Hash the dimensionless time to a bucket.
void ResizeUp(void)
Double the number of buckets if necessary.
virtual Scheduler::Event PeekNext(void) const
Get a pointer to the next event.
Scheduler::Event &(* NextEvent)(Bucket &bucket)
Get the next event from the bucket, according to m_reverse.
static TypeId GetTypeId(void)
Register this type.
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.
void DoResize(uint32_t newSize, uint64_t newWidth)
Resize the number of buckets and width.
uint32_t m_lastBucket
Bucket index from which the last event was dequeued.
virtual void Insert(const Scheduler::Event &ev)
Insert a new Event in the schedule.
void SetReverse(bool reverse)
Set the insertion order.
virtual ~CalendarScheduler()
Destructor.
void Resize(uint32_t newSize)
Resize to a new number of buckets, with automatically computed width.
uint64_t m_lastPrio
The priority of the last event removed.
uint64_t m_width
Duration of a bucket, in dimensionless time units.
Bucket * m_buckets
Array of buckets.
void ResizeDown(void)
Halve the number of buckets if necessary.
virtual Scheduler::Event RemoveNext(void)
Remove the earliest event from the event list.
virtual void Remove(const Scheduler::Event &ev)
Remove a specific event from the event list.
void(* Pop)(Bucket &)
Pop the next event from the bucket, according to m_reverse.
void PrintInfo(void)
Print the configuration and bucket size distribution.
a unique identifier for an interface.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
make Callback use a separate empty type
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(void)
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.