A Discrete-Event Network Simulator
API
ns3::CalendarScheduler Class Reference

a calendar queue event scheduler More...

#include <calendar-scheduler.h>

+ Inheritance diagram for ns3::CalendarScheduler:
+ Collaboration diagram for ns3::CalendarScheduler:

Public Member Functions

 CalendarScheduler ()
 
virtual ~CalendarScheduler ()
 
virtual void Insert (const Event &ev)
 
virtual bool IsEmpty (void) const
 
virtual Event PeekNext (void) const
 
virtual void Remove (const Event &ev)
 
virtual Event RemoveNext (void)
 This method cannot be invoked if the list is empty. More...
 
- Public Member Functions inherited from ns3::Scheduler
virtual ~Scheduler ()=0
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose (void)
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator (void) const
 Get an iterator to the Objects aggregated to this one. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Implement the GetInstanceTypeId method defined in ObjectBase. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object. More...
 
void Initialize (void)
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Scheduler
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 Noop. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Private Types

typedef std::list< Scheduler::EventBucket
 

Private Member Functions

uint32_t CalculateNewWidth (void)
 
void DoInsert (const Event &ev)
 
Scheduler::Event DoRemoveNext (void)
 
void DoResize (uint32_t newSize, uint32_t newWidth)
 
uint32_t Hash (uint64_t key) const
 
void Init (uint32_t nBuckets, uint64_t width, uint64_t startPrio)
 
void PrintInfo (void)
 
void Resize (uint32_t newSize)
 
void ResizeDown (void)
 
void ResizeUp (void)
 

Private Attributes

Bucketm_buckets
 
uint64_t m_bucketTop
 
uint32_t m_lastBucket
 
uint64_t m_lastPrio
 
uint32_t m_nBuckets
 
uint32_t m_qSize
 
uint64_t m_width
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void DoDispose (void)
 Destructor implementation. More...
 
virtual void DoInitialize (void)
 Initialize() implementation. More...
 
virtual void NotifyNewAggregate (void)
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted (void)
 Notifier called once the ObjectBase is fully constructed. More...
 

Detailed Description

a calendar queue event scheduler

Introspection did not find any typical Config paths.

This event scheduler is a direct implementation of the algorithm known as a calendar queue. first published in 1988 in "Calendar Queues: A Fast O(1) Priority Queue Implementation for the Simulation Event Set Problem" by Randy Brown. There are many refinements published later but this class implements the original algorithm (to the best of my knowledge).

Note: This queue is much slower than I expected (much slower than the std::map queue) and this seems to be because the original resizing policy is horribly bad. This is most likely the reason why there have been so many variations published which all slightly tweak the resizing heuristics to obtain a better distribution of events across buckets.


No Attributes are defined for this type.
No TraceSources are defined for this type.
Size of this type is 88 bytes (on a 64-bit architecture).

Definition at line 53 of file calendar-scheduler.h.

Member Typedef Documentation

Constructor & Destructor Documentation

ns3::CalendarScheduler::CalendarScheduler ( )

Definition at line 52 of file calendar-scheduler.cc.

References Init(), m_qSize, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

ns3::CalendarScheduler::~CalendarScheduler ( )
virtual

Definition at line 58 of file calendar-scheduler.cc.

References m_buckets, and NS_LOG_FUNCTION.

Member Function Documentation

uint32_t ns3::CalendarScheduler::CalculateNewWidth ( void  )
private

Definition at line 278 of file calendar-scheduler.cc.

References DoInsert(), DoRemoveNext(), m_bucketTop, m_lastBucket, m_lastPrio, m_qSize, and NS_LOG_FUNCTION.

Referenced by Resize().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::CalendarScheduler::DoInsert ( const Event ev)
private

Definition at line 100 of file calendar-scheduler.cc.

References Hash(), ns3::Scheduler::Event::key, m_buckets, ns3::Scheduler::EventKey::m_ts, ns3::Scheduler::EventKey::m_uid, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by CalculateNewWidth(), DoResize(), and Insert().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Scheduler::Event ns3::CalendarScheduler::DoRemoveNext ( void  )
private
void ns3::CalendarScheduler::DoResize ( uint32_t  newSize,
uint32_t  newWidth 
)
private

Definition at line 357 of file calendar-scheduler.cc.

References DoInsert(), Init(), m_buckets, m_lastPrio, m_nBuckets, and NS_LOG_FUNCTION.

Referenced by Resize().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TypeId ns3::CalendarScheduler::GetTypeId ( void  )
static

Definition at line 42 of file calendar-scheduler.cc.

References ns3::TypeId::SetParent().

+ Here is the call graph for this function:

uint32_t ns3::CalendarScheduler::Hash ( uint64_t  key) const
inlineprivate

Definition at line 91 of file calendar-scheduler.cc.

References m_nBuckets, m_width, and NS_LOG_FUNCTION.

Referenced by DoInsert(), DoRemoveNext(), Init(), and Remove().

+ Here is the caller graph for this function:

void ns3::CalendarScheduler::Init ( uint32_t  nBuckets,
uint64_t  width,
uint64_t  startPrio 
)
private

Definition at line 65 of file calendar-scheduler.cc.

References Hash(), m_buckets, m_bucketTop, m_lastBucket, m_lastPrio, m_nBuckets, m_width, and NS_LOG_FUNCTION.

Referenced by CalendarScheduler(), and DoResize().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::CalendarScheduler::Insert ( const Event ev)
virtual
Parameters
evevent to store in the event list

Implements ns3::Scheduler.

Definition at line 121 of file calendar-scheduler.cc.

References DoInsert(), m_qSize, NS_LOG_FUNCTION, and ResizeUp().

+ Here is the call graph for this function:

bool ns3::CalendarScheduler::IsEmpty ( void  ) const
virtual
Returns
true if the event list is empty and false otherwise.

Implements ns3::Scheduler.

Definition at line 129 of file calendar-scheduler.cc.

References m_qSize, and NS_LOG_FUNCTION.

Referenced by DoRemoveNext(), PeekNext(), Remove(), and RemoveNext().

+ Here is the caller graph for this function:

Scheduler::Event ns3::CalendarScheduler::PeekNext ( void  ) const
virtual
Returns
a pointer to the next earliest event. The caller takes ownership of the returned pointer.

This method cannot be invoked if the list is empty.

Implements ns3::Scheduler.

Definition at line 135 of file calendar-scheduler.cc.

References ns3::Scheduler::Event::impl, IsEmpty(), ns3::Scheduler::Event::key, m_buckets, m_bucketTop, ns3::Scheduler::EventKey::m_context, m_lastBucket, m_nBuckets, ns3::Scheduler::EventKey::m_ts, ns3::Scheduler::EventKey::m_uid, m_width, NS_ASSERT, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::CalendarScheduler::PrintInfo ( void  )
private

Definition at line 78 of file calendar-scheduler.cc.

References m_buckets, m_nBuckets, m_width, and NS_LOG_FUNCTION.

void ns3::CalendarScheduler::Remove ( const Event ev)
virtual
Parameters
evthe event to remove

This methods cannot be invoked if the list is empty.

Implements ns3::Scheduler.

Definition at line 232 of file calendar-scheduler.cc.

References Hash(), ns3::Scheduler::Event::impl, IsEmpty(), ns3::Scheduler::Event::key, m_buckets, m_qSize, ns3::Scheduler::EventKey::m_ts, ns3::Scheduler::EventKey::m_uid, NS_ASSERT, NS_LOG_FUNCTION, and ResizeDown().

+ Here is the call graph for this function:

Scheduler::Event ns3::CalendarScheduler::RemoveNext ( void  )
virtual

This method cannot be invoked if the list is empty.

Remove the next earliest event from the event list.

Implements ns3::Scheduler.

Definition at line 217 of file calendar-scheduler.cc.

References DoRemoveNext(), IsEmpty(), ns3::Scheduler::Event::key, m_bucketTop, m_lastBucket, m_qSize, ns3::Scheduler::EventKey::m_ts, ns3::Scheduler::EventKey::m_uid, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, and ResizeDown().

+ Here is the call graph for this function:

void ns3::CalendarScheduler::Resize ( uint32_t  newSize)
private

Definition at line 376 of file calendar-scheduler.cc.

References CalculateNewWidth(), DoResize(), and NS_LOG_FUNCTION.

Referenced by ResizeDown(), and ResizeUp().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::CalendarScheduler::ResizeDown ( void  )
private

Definition at line 267 of file calendar-scheduler.cc.

References m_nBuckets, m_qSize, NS_LOG_FUNCTION, and Resize().

Referenced by Remove(), and RemoveNext().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::CalendarScheduler::ResizeUp ( void  )
private

Definition at line 256 of file calendar-scheduler.cc.

References m_nBuckets, m_qSize, NS_LOG_FUNCTION, and Resize().

Referenced by Insert().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

Bucket* ns3::CalendarScheduler::m_buckets
private
uint64_t ns3::CalendarScheduler::m_bucketTop
private

Definition at line 90 of file calendar-scheduler.h.

Referenced by CalculateNewWidth(), DoRemoveNext(), Init(), PeekNext(), and RemoveNext().

uint32_t ns3::CalendarScheduler::m_lastBucket
private

Definition at line 88 of file calendar-scheduler.h.

Referenced by CalculateNewWidth(), DoRemoveNext(), Init(), PeekNext(), and RemoveNext().

uint64_t ns3::CalendarScheduler::m_lastPrio
private

Definition at line 92 of file calendar-scheduler.h.

Referenced by CalculateNewWidth(), DoRemoveNext(), DoResize(), and Init().

uint32_t ns3::CalendarScheduler::m_nBuckets
private
uint32_t ns3::CalendarScheduler::m_qSize
private
uint64_t ns3::CalendarScheduler::m_width
private

Definition at line 86 of file calendar-scheduler.h.

Referenced by DoRemoveNext(), Hash(), Init(), PeekNext(), and PrintInfo().


The documentation for this class was generated from the following files: