add SchedulerType global variable
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* Copyright (c) 2009 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -30,6 +30,18 @@ namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("CalendarScheduler");
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (CalendarScheduler);
|
||||
|
||||
TypeId
|
||||
CalendarScheduler::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::CalendarScheduler")
|
||||
.SetParent<Scheduler> ()
|
||||
.AddConstructor<CalendarScheduler> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
CalendarScheduler::CalendarScheduler ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* Copyright (c) 2009 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -31,10 +31,24 @@ class EventImpl;
|
||||
|
||||
/**
|
||||
* \ingroup scheduler
|
||||
* \brief 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.
|
||||
*/
|
||||
class CalendarScheduler : public Scheduler
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
CalendarScheduler ();
|
||||
virtual ~CalendarScheduler ();
|
||||
|
||||
|
||||
@@ -29,6 +29,17 @@ NS_LOG_COMPONENT_DEFINE ("HeapScheduler");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (HeapScheduler);
|
||||
|
||||
TypeId
|
||||
HeapScheduler::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::HeapScheduler")
|
||||
.SetParent<Scheduler> ()
|
||||
.AddConstructor<HeapScheduler> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
HeapScheduler::HeapScheduler ()
|
||||
{
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace ns3 {
|
||||
class HeapScheduler : public Scheduler
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
HeapScheduler ();
|
||||
virtual ~HeapScheduler ();
|
||||
|
||||
|
||||
@@ -27,6 +27,18 @@
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (ListScheduler);
|
||||
|
||||
TypeId
|
||||
ListScheduler::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::ListScheduler")
|
||||
.SetParent<Scheduler> ()
|
||||
.AddConstructor<ListScheduler> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
ListScheduler::ListScheduler ()
|
||||
{}
|
||||
ListScheduler::~ListScheduler ()
|
||||
|
||||
@@ -40,6 +40,8 @@ class EventImpl;
|
||||
class ListScheduler : public Scheduler
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
ListScheduler ();
|
||||
virtual ~ListScheduler ();
|
||||
|
||||
|
||||
@@ -29,6 +29,18 @@ NS_LOG_COMPONENT_DEFINE ("MapScheduler");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (MapScheduler);
|
||||
|
||||
TypeId
|
||||
MapScheduler::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::MapScheduler")
|
||||
.SetParent<Scheduler> ()
|
||||
.AddConstructor<MapScheduler> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
MapScheduler::MapScheduler ()
|
||||
{}
|
||||
MapScheduler::~MapScheduler ()
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace ns3 {
|
||||
class MapScheduler : public Scheduler
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
MapScheduler ();
|
||||
virtual ~MapScheduler ();
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "default-simulator-impl.h"
|
||||
#include "realtime-simulator-impl.h"
|
||||
#include "scheduler.h"
|
||||
#include "map-scheduler.h"
|
||||
#include "event-impl.h"
|
||||
|
||||
#include "ns3/ptr.h"
|
||||
@@ -48,6 +47,12 @@ GlobalValue g_simTypeImpl = GlobalValue ("SimulatorImplementationType",
|
||||
StringValue ("ns3::DefaultSimulatorImpl"),
|
||||
MakeStringChecker ());
|
||||
|
||||
GlobalValue g_schedTypeImpl = GlobalValue ("SchedulerType",
|
||||
"The object class to use as the scheduler implementation",
|
||||
StringValue ("ns3::MapScheduler"),
|
||||
MakeStringChecker ());
|
||||
|
||||
|
||||
#ifdef NS3_LOG_ENABLE
|
||||
|
||||
//
|
||||
@@ -77,15 +82,21 @@ static SimulatorImpl * GetImpl (void)
|
||||
*/
|
||||
if (impl == 0)
|
||||
{
|
||||
ObjectFactory factory;
|
||||
StringValue s;
|
||||
|
||||
g_simTypeImpl.GetValue (s);
|
||||
factory.SetTypeId (s.Get ());
|
||||
impl = factory.Create<SimulatorImpl> ();
|
||||
|
||||
Ptr<Scheduler> scheduler = CreateObject<MapScheduler> ();
|
||||
impl->SetScheduler (scheduler);
|
||||
{
|
||||
ObjectFactory factory;
|
||||
StringValue s;
|
||||
|
||||
g_simTypeImpl.GetValue (s);
|
||||
factory.SetTypeId (s.Get ());
|
||||
impl = factory.Create<SimulatorImpl> ();
|
||||
}
|
||||
{
|
||||
ObjectFactory factory;
|
||||
StringValue s;
|
||||
g_schedTypeImpl.GetValue (s);
|
||||
factory.SetTypeId (s.Get ());
|
||||
impl->SetScheduler (factory.Create<Scheduler> ());
|
||||
}
|
||||
|
||||
//
|
||||
// Note: we call LogSetTimePrinter _after_ creating the implementation
|
||||
@@ -302,6 +313,7 @@ Simulator::GetImplementation (void)
|
||||
#include "ns3/ptr.h"
|
||||
#include "list-scheduler.h"
|
||||
#include "heap-scheduler.h"
|
||||
#include "map-scheduler.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user