src/core/model/heap-scheduler.cc
changeset 9134 7a750f032acd
parent 7383 c5e131450339
child 9138 967a214aeb54
--- a/src/core/model/heap-scheduler.cc	Sat Nov 10 18:45:37 2012 +0100
+++ b/src/core/model/heap-scheduler.cc	Sat Nov 10 19:16:38 2012 +0100
@@ -34,6 +34,7 @@
 TypeId
 HeapScheduler::GetTypeId (void)
 {
+  NS_LOG_FUNCTION_NOARGS ();
   static TypeId tid = TypeId ("ns3::HeapScheduler")
     .SetParent<Scheduler> ()
     .AddConstructor<HeapScheduler> ()
@@ -43,6 +44,7 @@
 
 HeapScheduler::HeapScheduler ()
 {
+  NS_LOG_FUNCTION (this);
   // we purposedly waste an item at the start of
   // the array to make sure the indexes in the
   // array start at one.
@@ -52,44 +54,52 @@
 
 HeapScheduler::~HeapScheduler ()
 {
+  NS_LOG_FUNCTION (this);
 }
 
 uint32_t
 HeapScheduler::Parent (uint32_t id) const
 {
+  NS_LOG_FUNCTION (this << id);
   return id / 2;
 }
 uint32_t
 HeapScheduler::Sibling (uint32_t id) const
 {
+  NS_LOG_FUNCTION (this << id);
   return id + 1;
 }
 uint32_t
 HeapScheduler::LeftChild (uint32_t id) const
 {
+  NS_LOG_FUNCTION (this << id);
   return id * 2;
 }
 uint32_t
 HeapScheduler::RightChild (uint32_t id) const
 {
+  NS_LOG_FUNCTION (this << id);
   return id * 2 + 1;
 }
 
 uint32_t
 HeapScheduler::Root (void) const
 {
+  NS_LOG_FUNCTION (this);
   return 1;
 }
 
 bool
 HeapScheduler::IsRoot (uint32_t id) const
 {
+  NS_LOG_FUNCTION (this << id);
   return (id == Root ()) ? true : false;
 }
 
 uint32_t
 HeapScheduler::Last (void) const
 {
+  NS_LOG_FUNCTION (this);
   return m_heap.size () - 1;
 }
 
@@ -97,12 +107,14 @@
 bool
 HeapScheduler::IsBottom (uint32_t id) const
 {
+  NS_LOG_FUNCTION (this << id);
   return (id >= m_heap.size ()) ? true : false;
 }
 
 void
 HeapScheduler::Exch (uint32_t a, uint32_t b)
 {
+  NS_LOG_FUNCTION (this << a << b);
   NS_ASSERT (b < m_heap.size () && a < m_heap.size ());
   NS_LOG_DEBUG ("Exch " << a << ", " << b);
   Event tmp (m_heap[a]);
@@ -113,24 +125,28 @@
 bool
 HeapScheduler::IsLessStrictly (uint32_t a, uint32_t b) const
 {
+  NS_LOG_FUNCTION (this << a << b);
   return m_heap[a] < m_heap[b];
 }
 
 uint32_t
 HeapScheduler::Smallest (uint32_t a, uint32_t b) const
 {
+  NS_LOG_FUNCTION (this << a << b);
   return IsLessStrictly (a,b) ? a : b;
 }
 
 bool
 HeapScheduler::IsEmpty (void) const
 {
+  NS_LOG_FUNCTION (this);
   return (m_heap.size () == 1) ? true : false;
 }
 
 void
 HeapScheduler::BottomUp (void)
 {
+  NS_LOG_FUNCTION (this);
   uint32_t index = Last ();
   while (!IsRoot (index)
          && IsLessStrictly (index, Parent (index)))
@@ -143,6 +159,7 @@
 void
 HeapScheduler::TopDown (uint32_t start)
 {
+  NS_LOG_FUNCTION (this << start);
   uint32_t index = start;
   uint32_t right = RightChild (index);
   while (!IsBottom (right))
@@ -178,6 +195,7 @@
 void
 HeapScheduler::Insert (const Event &ev)
 {
+  NS_LOG_FUNCTION (this << &ev);
   m_heap.push_back (ev);
   BottomUp ();
 }
@@ -185,11 +203,13 @@
 Scheduler::Event
 HeapScheduler::PeekNext (void) const
 {
+  NS_LOG_FUNCTION (this);
   return m_heap[Root ()];
 }
 Scheduler::Event
 HeapScheduler::RemoveNext (void)
 {
+  NS_LOG_FUNCTION (this);
   Event next = m_heap[Root ()];
   Exch (Root (), Last ());
   m_heap.pop_back ();
@@ -201,6 +221,7 @@
 void
 HeapScheduler::Remove (const Event &ev)
 {
+  NS_LOG_FUNCTION (this << &ev);
   uint32_t uid = ev.key.m_uid;
   for (uint32_t i = 1; i < m_heap.size (); i++)
     {