ns3::CalendarScheduler Class Reference
[Scheduler]

a calendar queue event scheduler More...

#include <calendar-scheduler.h>

Inheritance diagram for ns3::CalendarScheduler:
Inheritance graph
[legend]
Collaboration diagram for ns3::CalendarScheduler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CalendarScheduler ()
virtual ~CalendarScheduler ()
virtual void Insert (const Event &ev)
virtual bool IsEmpty (void) const
virtual Event PeekNext (void) const
virtual Event RemoveNext (void)
virtual void Remove (const Event &ev)

Static Public Member Functions

static TypeId GetTypeId (void)
 This method returns the TypeId associated to ns3::CalendarScheduler.

Private Types

typedef std::list
< Scheduler::Event
Bucket

Private Member Functions

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

Private Attributes

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

Detailed Description

a calendar queue event scheduler

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.

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


Member Typedef Documentation

typedef std::list<Scheduler::Event> ns3::CalendarScheduler::Bucket [private]

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


Constructor & Destructor Documentation

ns3::CalendarScheduler::CalendarScheduler (  ) 

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

ns3::CalendarScheduler::~CalendarScheduler (  )  [virtual]

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

References Init(), m_qSize, and NS_LOG_FUNCTION.


Member Function Documentation

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

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

References m_nBuckets, and Resize().

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

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

References m_nBuckets, and m_width.

Referenced by IsEmpty(), and Resize().

Scheduler::Event ns3::CalendarScheduler::DoRemoveNext ( void   )  [private]

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

void ns3::CalendarScheduler::DoResize ( uint32_t  newSize,
uint32_t  newWidth 
) [private]

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

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

This method returns the TypeId associated to ns3::CalendarScheduler.

No Attributes defined for this type.
No TraceSources defined for this type.

Reimplemented from ns3::Scheduler.

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

uint32_t ns3::CalendarScheduler::Hash ( uint64_t  key  )  const [inline, private]

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

References m_buckets.

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

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

References m_buckets, and NS_LOG_FUNCTION.

Referenced by ~CalendarScheduler().

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

Implements ns3::Scheduler.

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

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

Implements ns3::Scheduler.

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

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

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 116 of file calendar-scheduler.cc.

References m_qSize.

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

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

void ns3::CalendarScheduler::Remove ( const Event ev  )  [virtual]
Parameters:
ev the event to remove

This methods cannot be invoked if the list is empty.

Implements ns3::Scheduler.

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

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 181 of file calendar-scheduler.cc.

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

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

References DoInsert().

Referenced by CalculateNewWidth(), and ResizeDown().

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

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

References m_nBuckets, and Resize().

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

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

Referenced by IsEmpty().


Member Data Documentation

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

Referenced by Hash(), and Init().

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

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

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

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

Referenced by CalculateNewWidth(), DoInsert(), and ResizeDown().

uint32_t ns3::CalendarScheduler::m_qSize [private]

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

Referenced by IsEmpty(), PeekNext(), and ~CalendarScheduler().

uint64_t ns3::CalendarScheduler::m_width [private]

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

Referenced by DoInsert().


The documentation for this class was generated from the following files:
Generated on Thu Dec 3 14:12:12 2009 for NS-3 by  doxygen 1.6.3