src/simulator/scheduler-list.cc
changeset 1009 adc3ac9baea8
parent 1008 6f2ea723a1db
child 1012 7b923896f33b
equal deleted inserted replaced
1008:6f2ea723a1db 1009:adc3ac9baea8
    65       return false;
    65       return false;
    66     }
    66     }
    67 }
    67 }
    68 
    68 
    69 void
    69 void
    70 SchedulerList::RealInsert (EventId id)
    70 SchedulerList::Insert (const EventId &id)
    71 {
    71 {
    72   Scheduler::EventKey key;
    72   Scheduler::EventKey key;
    73   // acquire refcount on EventImpl
    73   // acquire refcount on EventImpl
    74   EventImpl *event = GetPointer (id.GetEventImpl ());
    74   EventImpl *event = GetPointer (id.GetEventImpl ());
    75   key.m_ts = id.GetTs ();
    75   key.m_ts = id.GetTs ();
    83         }
    83         }
    84     }
    84     }
    85   m_events.push_back (std::make_pair (event, key));
    85   m_events.push_back (std::make_pair (event, key));
    86 }
    86 }
    87 bool 
    87 bool 
    88 SchedulerList::RealIsEmpty (void) const
    88 SchedulerList::IsEmpty (void) const
    89 {
    89 {
    90   return m_events.empty ();
    90   return m_events.empty ();
    91 }
    91 }
    92 EventId
    92 EventId
    93 SchedulerList::RealPeekNext (void) const
    93 SchedulerList::PeekNext (void) const
    94 {
    94 {
    95   std::pair<EventImpl *, EventKey> next = m_events.front ();
    95   std::pair<EventImpl *, EventKey> next = m_events.front ();
    96   return EventId (next.first, next.second.m_ts, next.second.m_uid);
    96   return EventId (next.first, next.second.m_ts, next.second.m_uid);
    97 }
    97 }
    98 
    98 
    99 void
    99 EventId
   100 SchedulerList::RealRemoveNext (void)
   100 SchedulerList::RemoveNext (void)
   101 {
   101 {
   102   std::pair<EventImpl *, EventKey> next = m_events.front ();
   102   std::pair<EventImpl *, EventKey> next = m_events.front ();
   103   // release single acquired ref.
       
   104   next.first->Unref ();
       
   105   m_events.pop_front ();
   103   m_events.pop_front ();
       
   104   return EventId (Ptr<EventImpl> (next.first,false), next.second.m_ts, next.second.m_uid);
   106 }
   105 }
   107 
   106 
   108 bool
   107 bool
   109 SchedulerList::RealRemove (EventId id)
   108 SchedulerList::Remove (const EventId &id)
   110 {
   109 {
   111   for (EventsI i = m_events.begin (); i != m_events.end (); i++) 
   110   for (EventsI i = m_events.begin (); i != m_events.end (); i++) 
   112     {
   111     {
   113       if (i->second.m_uid == id.GetUid ())
   112       if (i->second.m_uid == id.GetUid ())
   114         {
   113         {