bug 143: rename scheduler files
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
* to move one if statement out of the loop.
|
||||
*/
|
||||
|
||||
#include "scheduler-heap.h"
|
||||
#include "heap-scheduler.h"
|
||||
#include "event-impl.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
@@ -52,7 +52,7 @@ std::cout << "HEAP TRACE " << x << std::endl;
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
SchedulerHeap::SchedulerHeap ()
|
||||
HeapScheduler::HeapScheduler ()
|
||||
{
|
||||
// we purposedly waste an item at the start of
|
||||
// the array to make sure the indexes in the
|
||||
@@ -61,57 +61,57 @@ SchedulerHeap::SchedulerHeap ()
|
||||
m_heap.push_back (std::make_pair (static_cast<EventImpl *>(0), emptyKey));
|
||||
}
|
||||
|
||||
SchedulerHeap::~SchedulerHeap ()
|
||||
HeapScheduler::~HeapScheduler ()
|
||||
{}
|
||||
|
||||
uint32_t
|
||||
SchedulerHeap::Parent (uint32_t id) const
|
||||
HeapScheduler::Parent (uint32_t id) const
|
||||
{
|
||||
return id / 2;
|
||||
}
|
||||
uint32_t
|
||||
SchedulerHeap::Sibling (uint32_t id) const
|
||||
HeapScheduler::Sibling (uint32_t id) const
|
||||
{
|
||||
return id + 1;
|
||||
}
|
||||
uint32_t
|
||||
SchedulerHeap::LeftChild (uint32_t id) const
|
||||
HeapScheduler::LeftChild (uint32_t id) const
|
||||
{
|
||||
return id * 2;
|
||||
}
|
||||
uint32_t
|
||||
SchedulerHeap::RightChild (uint32_t id) const
|
||||
HeapScheduler::RightChild (uint32_t id) const
|
||||
{
|
||||
return id * 2 + 1;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SchedulerHeap::Root (void) const
|
||||
HeapScheduler::Root (void) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool
|
||||
SchedulerHeap::IsRoot (uint32_t id) const
|
||||
HeapScheduler::IsRoot (uint32_t id) const
|
||||
{
|
||||
return (id == Root ())?true:false;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SchedulerHeap::Last (void) const
|
||||
HeapScheduler::Last (void) const
|
||||
{
|
||||
return m_heap.size () - 1;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SchedulerHeap::IsBottom (uint32_t id) const
|
||||
HeapScheduler::IsBottom (uint32_t id) const
|
||||
{
|
||||
return (id >= m_heap.size ())?true:false;
|
||||
}
|
||||
|
||||
void
|
||||
SchedulerHeap::Exch (uint32_t a, uint32_t b)
|
||||
HeapScheduler::Exch (uint32_t a, uint32_t b)
|
||||
{
|
||||
NS_ASSERT (b < m_heap.size () && a < m_heap.size ());
|
||||
TRACE ("Exch " << a << ", " << b);
|
||||
@@ -121,7 +121,7 @@ SchedulerHeap::Exch (uint32_t a, uint32_t b)
|
||||
}
|
||||
|
||||
bool
|
||||
SchedulerHeap::IsLowerStrictly (Scheduler::EventKey const*a, Scheduler::EventKey const*b) const
|
||||
HeapScheduler::IsLowerStrictly (Scheduler::EventKey const*a, Scheduler::EventKey const*b) const
|
||||
{
|
||||
if (a->m_ts < b->m_ts)
|
||||
{
|
||||
@@ -142,25 +142,25 @@ SchedulerHeap::IsLowerStrictly (Scheduler::EventKey const*a, Scheduler::EventKey
|
||||
}
|
||||
|
||||
bool
|
||||
SchedulerHeap::IsLessStrictly (uint32_t a, uint32_t b) const
|
||||
HeapScheduler::IsLessStrictly (uint32_t a, uint32_t b) const
|
||||
{
|
||||
return IsLowerStrictly (&m_heap[a].second, &m_heap[b].second);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SchedulerHeap::Smallest (uint32_t a, uint32_t b) const
|
||||
HeapScheduler::Smallest (uint32_t a, uint32_t b) const
|
||||
{
|
||||
return IsLessStrictly (a,b)?a:b;
|
||||
}
|
||||
|
||||
bool
|
||||
SchedulerHeap::IsEmpty (void) const
|
||||
HeapScheduler::IsEmpty (void) const
|
||||
{
|
||||
return (m_heap.size () == 1)?true:false;
|
||||
}
|
||||
|
||||
void
|
||||
SchedulerHeap::BottomUp (void)
|
||||
HeapScheduler::BottomUp (void)
|
||||
{
|
||||
uint32_t index = Last ();
|
||||
while (!IsRoot (index) &&
|
||||
@@ -172,7 +172,7 @@ SchedulerHeap::BottomUp (void)
|
||||
}
|
||||
|
||||
void
|
||||
SchedulerHeap::TopDown (uint32_t start)
|
||||
HeapScheduler::TopDown (uint32_t start)
|
||||
{
|
||||
uint32_t index = start;
|
||||
uint32_t right = RightChild (index);
|
||||
@@ -207,7 +207,7 @@ SchedulerHeap::TopDown (uint32_t start)
|
||||
|
||||
|
||||
void
|
||||
SchedulerHeap::Insert (const EventId &id)
|
||||
HeapScheduler::Insert (const EventId &id)
|
||||
{
|
||||
// acquire single ref
|
||||
EventImpl *event = id.PeekEventImpl ();
|
||||
@@ -220,13 +220,13 @@ SchedulerHeap::Insert (const EventId &id)
|
||||
}
|
||||
|
||||
EventId
|
||||
SchedulerHeap::PeekNext (void) const
|
||||
HeapScheduler::PeekNext (void) const
|
||||
{
|
||||
std::pair<EventImpl *,Scheduler::EventKey> next = m_heap[Root ()];
|
||||
return EventId (next.first, next.second.m_ts, next.second.m_uid);
|
||||
}
|
||||
EventId
|
||||
SchedulerHeap::RemoveNext (void)
|
||||
HeapScheduler::RemoveNext (void)
|
||||
{
|
||||
std::pair<EventImpl *,Scheduler::EventKey> next = m_heap[Root ()];
|
||||
Exch (Root (), Last ());
|
||||
@@ -237,7 +237,7 @@ SchedulerHeap::RemoveNext (void)
|
||||
|
||||
|
||||
bool
|
||||
SchedulerHeap::Remove (const EventId &id)
|
||||
HeapScheduler::Remove (const EventId &id)
|
||||
{
|
||||
uint32_t uid = id.GetUid ();
|
||||
for (uint32_t i = 1; i < m_heap.size (); i++)
|
||||
@@ -29,10 +29,10 @@ namespace ns3 {
|
||||
|
||||
class EventHolder;
|
||||
|
||||
class SchedulerHeap : public Scheduler {
|
||||
class HeapScheduler : public Scheduler {
|
||||
public:
|
||||
SchedulerHeap ();
|
||||
virtual ~SchedulerHeap ();
|
||||
HeapScheduler ();
|
||||
virtual ~HeapScheduler ();
|
||||
|
||||
virtual void Insert (const EventId &id);
|
||||
virtual bool IsEmpty (void) const;
|
||||
@@ -18,7 +18,7 @@
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "scheduler-list.h"
|
||||
#include "list-scheduler.h"
|
||||
#include "event-impl.h"
|
||||
#include <utility>
|
||||
#include <string>
|
||||
@@ -27,13 +27,13 @@
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
SchedulerList::SchedulerList ()
|
||||
ListScheduler::ListScheduler ()
|
||||
{}
|
||||
SchedulerList::~SchedulerList ()
|
||||
ListScheduler::~ListScheduler ()
|
||||
{}
|
||||
|
||||
bool
|
||||
SchedulerList::IsLower (Scheduler::EventKey const*a, Scheduler::EventKey const*b) const
|
||||
ListScheduler::IsLower (Scheduler::EventKey const*a, Scheduler::EventKey const*b) const
|
||||
{
|
||||
if (a->m_ts < b->m_ts)
|
||||
{
|
||||
@@ -51,7 +51,7 @@ SchedulerList::IsLower (Scheduler::EventKey const*a, Scheduler::EventKey const*b
|
||||
}
|
||||
|
||||
void
|
||||
SchedulerList::Insert (const EventId &id)
|
||||
ListScheduler::Insert (const EventId &id)
|
||||
{
|
||||
Scheduler::EventKey key;
|
||||
// acquire refcount on EventImpl
|
||||
@@ -70,19 +70,19 @@ SchedulerList::Insert (const EventId &id)
|
||||
m_events.push_back (std::make_pair (event, key));
|
||||
}
|
||||
bool
|
||||
SchedulerList::IsEmpty (void) const
|
||||
ListScheduler::IsEmpty (void) const
|
||||
{
|
||||
return m_events.empty ();
|
||||
}
|
||||
EventId
|
||||
SchedulerList::PeekNext (void) const
|
||||
ListScheduler::PeekNext (void) const
|
||||
{
|
||||
std::pair<EventImpl *, EventKey> next = m_events.front ();
|
||||
return EventId (next.first, next.second.m_ts, next.second.m_uid);
|
||||
}
|
||||
|
||||
EventId
|
||||
SchedulerList::RemoveNext (void)
|
||||
ListScheduler::RemoveNext (void)
|
||||
{
|
||||
std::pair<EventImpl *, EventKey> next = m_events.front ();
|
||||
m_events.pop_front ();
|
||||
@@ -90,7 +90,7 @@ SchedulerList::RemoveNext (void)
|
||||
}
|
||||
|
||||
bool
|
||||
SchedulerList::Remove (const EventId &id)
|
||||
ListScheduler::Remove (const EventId &id)
|
||||
{
|
||||
for (EventsI i = m_events.begin (); i != m_events.end (); i++)
|
||||
{
|
||||
@@ -31,10 +31,10 @@ namespace ns3 {
|
||||
|
||||
class EventImpl;
|
||||
|
||||
class SchedulerList : public Scheduler {
|
||||
class ListScheduler : public Scheduler {
|
||||
public:
|
||||
SchedulerList ();
|
||||
virtual ~SchedulerList ();
|
||||
ListScheduler ();
|
||||
virtual ~ListScheduler ();
|
||||
|
||||
virtual void Insert (const EventId &id);
|
||||
virtual bool IsEmpty (void) const;
|
||||
@@ -19,7 +19,7 @@
|
||||
* The idea to use a std c++ map came from GTNetS
|
||||
*/
|
||||
|
||||
#include "scheduler-map.h"
|
||||
#include "map-scheduler.h"
|
||||
#include "event-impl.h"
|
||||
#include "ns3/assert.h"
|
||||
#include <string>
|
||||
@@ -37,9 +37,9 @@ std::cout << "MAP TRACE " << x << std::endl;
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
SchedulerMap::SchedulerMap ()
|
||||
MapScheduler::MapScheduler ()
|
||||
{}
|
||||
SchedulerMap::~SchedulerMap ()
|
||||
MapScheduler::~MapScheduler ()
|
||||
{}
|
||||
|
||||
/* Note the invariants which this function must provide:
|
||||
@@ -48,7 +48,7 @@ SchedulerMap::~SchedulerMap ()
|
||||
* - transitivity: f(x,y) and f(y,z) => f(x,z)
|
||||
*/
|
||||
bool
|
||||
SchedulerMap::EventKeyCompare::operator () (struct EventKey const&a, struct EventKey const&b)
|
||||
MapScheduler::EventKeyCompare::operator () (struct EventKey const&a, struct EventKey const&b)
|
||||
{
|
||||
if (a.m_ts < b.m_ts)
|
||||
{
|
||||
@@ -71,7 +71,7 @@ SchedulerMap::EventKeyCompare::operator () (struct EventKey const&a, struct Even
|
||||
|
||||
|
||||
void
|
||||
SchedulerMap::Insert (const EventId &id)
|
||||
MapScheduler::Insert (const EventId &id)
|
||||
{
|
||||
// acquire a single ref
|
||||
EventImpl *event = id.PeekEventImpl ();
|
||||
@@ -85,13 +85,13 @@ SchedulerMap::Insert (const EventId &id)
|
||||
}
|
||||
|
||||
bool
|
||||
SchedulerMap::IsEmpty (void) const
|
||||
MapScheduler::IsEmpty (void) const
|
||||
{
|
||||
return m_list.empty ();
|
||||
}
|
||||
|
||||
EventId
|
||||
SchedulerMap::PeekNext (void) const
|
||||
MapScheduler::PeekNext (void) const
|
||||
{
|
||||
EventMapCI i = m_list.begin ();
|
||||
NS_ASSERT (i != m_list.end ());
|
||||
@@ -99,7 +99,7 @@ SchedulerMap::PeekNext (void) const
|
||||
return EventId (i->second, i->first.m_ts, i->first.m_uid);
|
||||
}
|
||||
EventId
|
||||
SchedulerMap::RemoveNext (void)
|
||||
MapScheduler::RemoveNext (void)
|
||||
{
|
||||
EventMapI i = m_list.begin ();
|
||||
std::pair<Scheduler::EventKey, EventImpl*> next = *i;
|
||||
@@ -108,7 +108,7 @@ SchedulerMap::RemoveNext (void)
|
||||
}
|
||||
|
||||
bool
|
||||
SchedulerMap::Remove (const EventId &id)
|
||||
MapScheduler::Remove (const EventId &id)
|
||||
{
|
||||
Scheduler::EventKey key;
|
||||
key.m_ts = id.GetTs ();
|
||||
@@ -30,10 +30,10 @@ namespace ns3 {
|
||||
|
||||
class EventImpl;
|
||||
|
||||
class SchedulerMap : public Scheduler {
|
||||
class MapScheduler : public Scheduler {
|
||||
public:
|
||||
SchedulerMap ();
|
||||
virtual ~SchedulerMap ();
|
||||
MapScheduler ();
|
||||
virtual ~MapScheduler ();
|
||||
|
||||
virtual void Insert (const EventId &id);
|
||||
virtual bool IsEmpty (void) const;
|
||||
@@ -47,9 +47,9 @@ private:
|
||||
bool operator () (struct EventKey const&a, struct EventKey const&b);
|
||||
};
|
||||
|
||||
typedef std::map<Scheduler::EventKey, EventImpl*, SchedulerMap::EventKeyCompare> EventMap;
|
||||
typedef std::map<Scheduler::EventKey, EventImpl*, SchedulerMap::EventKeyCompare>::iterator EventMapI;
|
||||
typedef std::map<Scheduler::EventKey, EventImpl*, SchedulerMap::EventKeyCompare>::const_iterator EventMapCI;
|
||||
typedef std::map<Scheduler::EventKey, EventImpl*, MapScheduler::EventKeyCompare> EventMap;
|
||||
typedef std::map<Scheduler::EventKey, EventImpl*, MapScheduler::EventKeyCompare>::iterator EventMapI;
|
||||
typedef std::map<Scheduler::EventKey, EventImpl*, MapScheduler::EventKeyCompare>::const_iterator EventMapCI;
|
||||
|
||||
|
||||
EventMap m_list;
|
||||
@@ -393,9 +393,7 @@ SimulatorPrivate::GetMaximumSimulationTime (void) const
|
||||
}; // namespace ns3
|
||||
|
||||
|
||||
#include "scheduler-list.h"
|
||||
#include "scheduler-heap.h"
|
||||
#include "scheduler-map.h"
|
||||
#include "map-scheduler.h"
|
||||
|
||||
|
||||
namespace ns3 {
|
||||
@@ -418,7 +416,7 @@ Simulator::GetPriv (void)
|
||||
if (m_priv == 0)
|
||||
{
|
||||
m_priv = CreateObject<SimulatorPrivate> ();
|
||||
Ptr<Scheduler> scheduler = CreateObject<SchedulerMap> ();
|
||||
Ptr<Scheduler> scheduler = CreateObject<MapScheduler> ();
|
||||
m_priv->SetScheduler (scheduler);
|
||||
}
|
||||
TRACE_S ("priv " << m_priv);
|
||||
@@ -564,6 +562,8 @@ Simulator::GetMaximumSimulationTime (void)
|
||||
|
||||
#include "ns3/test.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "list-scheduler.h"
|
||||
#include "heap-scheduler.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -934,19 +934,19 @@ SimulatorTests::RunTests (void)
|
||||
bool result = true;
|
||||
|
||||
Simulator::Destroy ();
|
||||
Simulator::SetScheduler (CreateObject<SchedulerList> ());
|
||||
Simulator::SetScheduler (CreateObject<ListScheduler> ());
|
||||
if (!RunOneTest ())
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
Simulator::Destroy ();
|
||||
Simulator::SetScheduler (CreateObject<SchedulerHeap> ());
|
||||
Simulator::SetScheduler (CreateObject<HeapScheduler> ());
|
||||
if (!RunOneTest ())
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
Simulator::Destroy ();
|
||||
Simulator::SetScheduler (CreateObject<SchedulerMap> ());
|
||||
Simulator::SetScheduler (CreateObject<MapScheduler> ());
|
||||
if (!RunOneTest ())
|
||||
{
|
||||
result = false;
|
||||
|
||||
@@ -53,9 +53,9 @@ def build(bld):
|
||||
'time.cc',
|
||||
'event-id.cc',
|
||||
'scheduler.cc',
|
||||
'scheduler-list.cc',
|
||||
'scheduler-heap.cc',
|
||||
'scheduler-map.cc',
|
||||
'list-scheduler.cc',
|
||||
'map-scheduler.cc',
|
||||
'heap-scheduler.cc',
|
||||
'event-impl.cc',
|
||||
'simulator.cc',
|
||||
'timer.cc',
|
||||
@@ -71,9 +71,9 @@ def build(bld):
|
||||
'event-impl.h',
|
||||
'simulator.h',
|
||||
'scheduler.h',
|
||||
'scheduler-list.h',
|
||||
'scheduler-map.h',
|
||||
'scheduler-heap.h',
|
||||
'list-scheduler.h',
|
||||
'map-scheduler.h',
|
||||
'heap-scheduler.h',
|
||||
'simulation-singleton.h',
|
||||
'timer.h',
|
||||
'timer-impl.h',
|
||||
|
||||
@@ -18,11 +18,8 @@
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/scheduler-list.h"
|
||||
#include "ns3/scheduler-map.h"
|
||||
#include "ns3/scheduler-heap.h"
|
||||
#include "ns3/system-wall-clock-ms.h"
|
||||
#include "ns3/simulator-module.h"
|
||||
#include "ns3/core-module.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
@@ -161,15 +158,15 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
if (strcmp ("--list", argv[0]) == 0)
|
||||
{
|
||||
Simulator::SetScheduler (CreateObject<SchedulerList> ());
|
||||
Simulator::SetScheduler (CreateObject<ListScheduler> ());
|
||||
}
|
||||
else if (strcmp ("--heap", argv[0]) == 0)
|
||||
{
|
||||
Simulator::SetScheduler (CreateObject<SchedulerHeap> ());
|
||||
Simulator::SetScheduler (CreateObject<HeapScheduler> ());
|
||||
}
|
||||
else if (strcmp ("--map", argv[0]) == 0)
|
||||
{
|
||||
Simulator::SetScheduler (CreateObject<SchedulerMap> ());
|
||||
Simulator::SetScheduler (CreateObject<MapScheduler> ());
|
||||
}
|
||||
else if (strcmp ("--debug", argv[0]) == 0)
|
||||
{
|
||||
|
||||
@@ -18,12 +18,8 @@
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/scheduler-list.h"
|
||||
#include "ns3/scheduler-map.h"
|
||||
#include "ns3/scheduler-heap.h"
|
||||
#include "ns3/nstime.h"
|
||||
#include "ns3/system-wall-clock-ms.h"
|
||||
#include "ns3/simulator-module.h"
|
||||
#include "ns3/core-module.h"
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <fstream>
|
||||
@@ -317,15 +313,15 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
if (is_map)
|
||||
{
|
||||
Simulator::SetScheduler (CreateObject<SchedulerMap> ());
|
||||
Simulator::SetScheduler (CreateObject<MapScheduler> ());
|
||||
}
|
||||
else if (is_list)
|
||||
{
|
||||
Simulator::SetScheduler (CreateObject<SchedulerList> ());
|
||||
Simulator::SetScheduler (CreateObject<ListScheduler> ());
|
||||
}
|
||||
else if (is_heap)
|
||||
{
|
||||
Simulator::SetScheduler (CreateObject<SchedulerHeap> ());
|
||||
Simulator::SetScheduler (CreateObject<HeapScheduler> ());
|
||||
}
|
||||
log.Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
Reference in New Issue
Block a user