-changing SchedulableList to SchedulableQueue: intermediate commit,

so SVN can let me use "mv"

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@602 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-06-03 14:40:19 +00:00
parent 16acaf51d9
commit 4508ed017b
16 changed files with 70 additions and 70 deletions

View File

@ -145,7 +145,7 @@ namespace sgpem {
// --------------------------------------------
class SchedulableList
class SchedulableQueue
{
public:
unsigned int size() const;
@ -154,10 +154,10 @@ namespace sgpem {
private:
// Avoid instantiation and copy
SchedulableList();
SchedulableList(const SchedulableList&);
SchedulableList& operator=(const SchedulableList&);
~SchedulableList();
SchedulableQueue();
SchedulableQueue(const SchedulableQueue&);
SchedulableQueue& operator=(const SchedulableQueue&);
~SchedulableQueue();
}; //~ class Schedulable
// ---------------------------------------------
@ -186,7 +186,7 @@ namespace sgpem {
public:
sgpem::Policy& get_policy();
static sgpem::Scheduler& get_instance();
sgpem::SchedulableList* get_ready_queue();
sgpem::SchedulableQueue* get_ready_queue();
private:
Scheduler();
~Scheduler();

View File

@ -104,7 +104,7 @@ main(int argc, char** argv) {
try
{
SchedulableList sl;
SchedulableQueue sl;
polman.test_init("python_loader_sort_queue");
polman.get_policy().sort_queue(Scheduler::event_schedulable_arrival);
}

View File

@ -47,7 +47,7 @@ History::get_instance()
/**
Returns a pointer to a copy of the SchedulableStatus object relative to this instant.
It can be NULL if time is out of range or if there are no running entities in the associated
SchedulableList
SchedulableQueue
*/
smart_ptr<SchedulableStatus>
History::get_scheduled_at(int time) const
@ -56,7 +56,7 @@ History::get_scheduled_at(int time) const
return smart_ptr<SchedulableStatus>(NULL);
//look for a runing entity
smart_ptr<SchedulableList> p = get_simulation_status_at(time);
smart_ptr<SchedulableQueue> p = get_simulation_status_at(time);
for (uint i = 0; i < p->size(); i++)
if (p->get_item_at(i)->get_state() == SchedulableStatus::state_running)
@ -69,21 +69,21 @@ History::get_scheduled_at(int time) const
Returns a pointer to a copy of the SimulationStatus object relative to this instant or NULL
if time is out of range.
*/
smart_ptr<SchedulableList>
smart_ptr<SchedulableQueue>
History::get_simulation_status_at(int time) const
{
if (time > _total_time_elapsed || time < 0) //out of range
return smart_ptr<SchedulableList>(NULL);
return smart_ptr<SchedulableQueue>(NULL);
int trascorso = -1;
for(vector<Slice>::const_iterator i=_slices.begin(); i < _slices.end(); i++)
if (time <= trascorso + i->get_duration()) //FOUND!!
return smart_ptr<SchedulableList>(new SchedulableList(*i->get_simulation_status()));
return smart_ptr<SchedulableQueue>(new SchedulableQueue(*i->get_simulation_status()));
else //Go on...
trascorso += i->get_duration();
//never reached if all slices are CONTIGUOUS (ans THIS shoul be!!)!!!
return smart_ptr<SchedulableList>(NULL);
return smart_ptr<SchedulableQueue>(NULL);
}
int
@ -97,7 +97,7 @@ History::get_current_time() const
Calls the method notify() in quality of ObservedSubject, updating all observers.
*/
void
History::enqueue_slice(const SchedulableList& status)
History::enqueue_slice(const SchedulableQueue& status)
{
if(_slices.size() == 0)
{

View File

@ -62,7 +62,7 @@ namespace sgpem
\param time The inquired time instant.
\return The list of Schedulable status objects at the specified time.
*/
virtual memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const;
virtual memory::smart_ptr<sgpem::SchedulableQueue> get_simulation_status_at(int time) const;
/**
Gets the current time.
@ -74,7 +74,7 @@ namespace sgpem
Sets the status of simulation at the current time.
\param status The list of \ref Schedulable status objects at the current time.
*/
virtual void enqueue_slice(const sgpem::SchedulableList& status);
virtual void enqueue_slice(const sgpem::SchedulableQueue& status);
/**
Remove all data in History following the specified time.

View File

@ -24,12 +24,12 @@ using namespace sgpem;
using namespace std;
using namespace memory;
SchedulableList::SchedulableList()
SchedulableQueue::SchedulableQueue()
{
}
SchedulableStatus*
SchedulableList::top()
SchedulableQueue::top()
{
if (_list.size() == 0)
return NULL;
@ -37,7 +37,7 @@ SchedulableList::top()
}
SchedulableStatus*
SchedulableList::bottom()
SchedulableQueue::bottom()
{
if (_list.size() == 0)
return NULL;
@ -51,7 +51,7 @@ SchedulableList::bottom()
DON'T call delete on the returned pointer! Its destruction is managed by the queue.
*/
SchedulableStatus*
SchedulableList::get_item_at(const uint& where)
SchedulableQueue::get_item_at(const uint& where)
{
if (_list.size() == 0 || where >= _list.size())
return NULL;
@ -63,7 +63,7 @@ SchedulableList::get_item_at(const uint& where)
}
const SchedulableStatus*
SchedulableList::get_item_at(const uint& where) const
SchedulableQueue::get_item_at(const uint& where) const
{
if (_list.size() == 0 || where >= _list.size())
return NULL;
@ -79,25 +79,25 @@ SchedulableList::get_item_at(const uint& where) const
*/
uint
SchedulableList::size() const
SchedulableQueue::size() const
{
return _list.size();
}
void
SchedulableList::add_at_top(const SchedulableStatus& ss)
SchedulableQueue::add_at_top(const SchedulableStatus& ss)
{
_list.push_front(ss);
}
void
SchedulableList::add_at_bottom(const SchedulableStatus& ss)
SchedulableQueue::add_at_bottom(const SchedulableStatus& ss)
{
_list.push_back(ss);
}
smart_ptr<SchedulableStatus>
SchedulableList::remove(const uint& position)
SchedulableQueue::remove(const uint& position)
{
if (_list.size() == 0 || position >= _list.size())
return smart_ptr<SchedulableStatus>(NULL);
@ -114,7 +114,7 @@ SchedulableList::remove(const uint& position)
*/
bool
SchedulableList::insert_at(const uint& which, const uint& where)
SchedulableQueue::insert_at(const uint& which, const uint& where)
{
//out of range
if (which >= _list.size() || where >= _list.size())
@ -144,7 +144,7 @@ SchedulableList::insert_at(const uint& which, const uint& where)
*/
void
SchedulableList::clear()
SchedulableQueue::clear()
{
_list.clear();
}
@ -154,7 +154,7 @@ SchedulableList::clear()
\brief Returns TRUE if the two objects have the same SchedulableStatus objects in the same order.
*/
bool
SchedulableList::operator==(const SchedulableList& dx) const
SchedulableQueue::operator==(const SchedulableQueue& dx) const
{
return _list == dx._list;
}
@ -164,7 +164,7 @@ SchedulableList::operator==(const SchedulableList& dx) const
\brief Returns TRUE if the two objects have the same SchedulableStatus objects with NO ORDER IMPORTANCE.
*/
bool
SchedulableList::has_same_objects(const SchedulableList& dx) const
SchedulableQueue::has_same_objects(const SchedulableQueue& dx) const
{
if (_list.size() != dx._list.size())
return false;
@ -179,7 +179,7 @@ SchedulableList::has_same_objects(const SchedulableList& dx) const
void
SchedulableList::swap(unsigned int positionA, unsigned int positionB) throw()
SchedulableQueue::swap(unsigned int positionA, unsigned int positionB) throw()
{
if (positionA == positionB || positionA >= _list.size() || positionB >= _list.size())
return;

View File

@ -31,14 +31,14 @@
namespace sgpem
{
class SchedulableList;
class SchedulableQueue;
class SG_DLLEXPORT SchedulableList
class SG_DLLEXPORT SchedulableQueue
{
public:
SchedulableList();
bool operator==(const SchedulableList&) const;
bool has_same_objects(const SchedulableList& dx) const;
SchedulableQueue();
bool operator==(const SchedulableQueue&) const;
bool has_same_objects(const SchedulableQueue& dx) const;
/** \brief Returns a pointer to the first element
*

View File

@ -46,7 +46,7 @@ Scheduler::get_instance()
return *_instance;
}
SchedulableList*
SchedulableQueue*
Scheduler::get_ready_queue()
{
return &_ready_queue;
@ -90,7 +90,7 @@ Scheduler::step_forward() throw(UserInterruptException)
//******************
//check for arrivals and prepare the queue
//******************
smart_ptr<SchedulableList> initial = h.get_simulation_status_at(h.get_current_time());
smart_ptr<SchedulableQueue> initial = h.get_simulation_status_at(h.get_current_time());
if (!initial)
{
cout << _("\nNo initial state inserted!!\n");

View File

@ -87,13 +87,13 @@ namespace sgpem
\return a pointer to the queue containing all the ready
schedulable objects (for the policy to sort it).
*/
SchedulableList* get_ready_queue();
SchedulableQueue* get_ready_queue();
/**
Resets the simulation to the initial state.
*/
void reset_status();
/**
Generates a new SchedulableList representing the status of the processes
Generates a new SchedulableQueue representing the status of the processes
at the simulation instant next to the current one, and extends the History by
one instant with it.
*/
@ -115,7 +115,7 @@ namespace sgpem
private:
Scheduler(); //private constructor.
static Scheduler* _instance;
SchedulableList _ready_queue;
SchedulableQueue _ready_queue;
PolicyManager& _policy_manager;
};

View File

@ -23,12 +23,12 @@ using namespace sgpem;
using namespace std;
Slice::Slice(const int& start, const int& duration, const SchedulableList& status)
Slice::Slice(const int& start, const int& duration, const SchedulableQueue& status)
: _ref(status), _started_at(start), _duration(duration)
{
}
const SchedulableList*
const SchedulableQueue*
Slice::get_simulation_status() const
{
return &_ref;

View File

@ -45,13 +45,13 @@ namespace sgpem
\param duration Time length of Slice.
\param status Photoshot of all \ref Schedulable during this Slice.
*/
Slice(const int& start, const int& duration, const SchedulableList& status);
Slice(const int& start, const int& duration, const SchedulableQueue& status);
/**
Gets a constant reference to the \ref SchedulableList object for this Slice.
\return The reference (constant) to the SchedulableList object for this Slice.
Gets a constant reference to the \ref SchedulableQueue object for this Slice.
\return The reference (constant) to the SchedulableQueue object for this Slice.
*/
const SchedulableList* get_simulation_status() const;
const SchedulableQueue* get_simulation_status() const;
/**
@ -73,7 +73,7 @@ namespace sgpem
void set_duration(const int& duration);
private:
SchedulableList _ref;
SchedulableQueue _ref;
int _started_at;
int _duration;
};

View File

@ -119,7 +119,7 @@ main(int argc, char* argv[])
SchedulableStatus ss5(p5);
SchedulableStatus ss6(p6);
SchedulableList initial;
SchedulableQueue initial;
initial.add_at_bottom(ss1);
initial.add_at_bottom(ss2);
initial.add_at_bottom(ss3);
@ -151,17 +151,17 @@ main(int argc, char* argv[])
// ************** TEST HISTORY
SchedulableList l1;
SchedulableQueue l1;
l1.add_at_top(ss1); l1.add_at_top(ss2); l1.add_at_top(ss3);
SchedulableList l2;
SchedulableQueue l2;
l2.add_at_top(ss4); l2.add_at_top(ss5); l2.add_at_top(ss6);
History h(History::get_instance());
h.enqueue_slice(l1); //stato iniziale
h.enqueue_slice(l2);
smart_ptr<const sgpem::SchedulableList> quale;
smart_ptr<const sgpem::SchedulableQueue> quale;
quale = h.get_simulation_status_at(0); //stato iniziale
@ -198,7 +198,7 @@ main(int argc, char* argv[])
//************** TEST QUEUE
/* cout << "\n\nTEST QUEUE\n";
SchedulableList sq;
SchedulableQueue sq;
sq.add_at_bottom(ss1);
sq.add_at_bottom(ss2);
sq.add_at_bottom(ss3);

View File

@ -98,7 +98,7 @@ Simulation::run() throw(UserInterruptException)
do {
// chech for termination
bool all_term = true;
smart_ptr<SchedulableList> left = h.get_simulation_status_at(h.get_current_time());
smart_ptr<SchedulableQueue> left = h.get_simulation_status_at(h.get_current_time());
for(uint i = 0; i < left->size(); i++)
if (left->get_item_at(i)->get_state() != SchedulableStatus::state_terminated)
{
@ -141,7 +141,7 @@ Simulation::run() throw(UserInterruptException)
{
// chech for termination
bool all_term = true;
smart_ptr<SchedulableList> left = h.get_simulation_status_at(h.get_current_time());
smart_ptr<SchedulableQueue> left = h.get_simulation_status_at(h.get_current_time());
for(uint i = 0; i < left->size(); i++)
if (left->get_item_at(i)->get_state() != SchedulableStatus::state_terminated)
{

View File

@ -45,7 +45,7 @@ using namespace std;
class HistoryTester
{
public:
HistoryTester(SchedulableList sl)
HistoryTester(SchedulableQueue sl)
: _history_length(-1), _internal_schedulable_list(sl)
{}
@ -82,9 +82,9 @@ public:
private:
int _history_length; // mirrors the correct length of the history
SchedulableList* _get_simulation_status_at[400]; // mirrors the correct content of the history
SchedulableQueue* _get_simulation_status_at[400]; // mirrors the correct content of the history
SchedulableStatus* _get_scheduled_at[400]; // mirrors the correct content of the history
SchedulableList _internal_schedulable_list;
SchedulableQueue _internal_schedulable_list;
// looks for anomalies
@ -113,13 +113,13 @@ public:
}
// saves the given SchedulableList into the history, and saves a copy of it into an array
void _insert(sgpem::SchedulableList& status)
// saves the given SchedulableQueue into the history, and saves a copy of it into an array
void _insert(sgpem::SchedulableQueue& status)
{
History::get_instance().enqueue_slice(status);
_history_length = _history_length + 1;
_get_simulation_status_at[_history_length] = new SchedulableList(status);
_get_simulation_status_at[_history_length] = new SchedulableQueue(status);
if (History::get_instance().get_scheduled_at(_history_length) != memory::smart_ptr<SchedulableStatus>(NULL))
_get_scheduled_at[_history_length] = new SchedulableStatus(*(status.top()));
@ -129,8 +129,8 @@ public:
}
// modifies the given SchedulableList object in an arbitrary way.
void _randomize(sgpem::SchedulableList& status)
// modifies the given SchedulableQueue object in an arbitrary way.
void _randomize(sgpem::SchedulableQueue& status)
{
status.swap(9, 10);
status.swap(1, 16);
@ -232,7 +232,7 @@ main(int argc, char** argv)
SchedulableStatus ss18(p18);
SchedulableStatus ss19(p19); // not used!
SchedulableList initial;
SchedulableQueue initial;
initial.add_at_bottom(ss1);
initial.add_at_bottom(ss2);
initial.add_at_bottom(ss3);

View File

@ -56,7 +56,7 @@ namespace sgpem
std::cout << "get_scheduled_at" << time;
return History::get_scheduled_at(time);
}
memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const
memory::smart_ptr<sgpem::SchedulableQueue> get_simulation_status_at(int time) const
{
std::cout << "get_simulation_status_at" << time;
return History::get_simulation_status_at(time);
@ -66,7 +66,7 @@ namespace sgpem
std::cout << "getCurrentTime";
return History::get_current_time();
}
void enqueue_slice(const sgpem::SchedulableList& status)
void enqueue_slice(const sgpem::SchedulableQueue& status)
{
std::cout << "enqueue_slice";
History::enqueue_slice(status);

View File

@ -82,7 +82,7 @@ namespace sgpem
virtual void sort_queue(Scheduler::event event) const throw(UserInterruptException)
{ // here a lot of fun, exactly O(n^2) fun!
SchedulableList sl = History.get_instance().get_simulation_status_at(get_current_time());
SchedulableQueue sl = History.get_instance().get_simulation_status_at(get_current_time());
for (int i = 0; i < sl.size(); i++)
{
for (int j = 0; j < sl.size()-1; j++)
@ -186,9 +186,9 @@ namespace sgpem
public:
memory::smart_ptr<sgpem::SchedulableStatus> get_scheduled_at(int time) const {}
memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const;
memory::smart_ptr<sgpem::SchedulableQueue> get_simulation_status_at(int time) const;
int get_current_time() const {return _total_time_elapsed;}
void enqueue_slice(const sgpem::SchedulableList& status);
void enqueue_slice(const sgpem::SchedulableQueue& status);
void truncate_at(int instant) {}
static History& get_instance();
private:
@ -272,7 +272,7 @@ main(int argc, char** argv) {
SchedulableStatus ss18(p18);
SchedulableStatus ss19(p19); // not used!
SchedulableList initial;
SchedulableQueue initial;
initial.add_at_bottom(ss1);
initial.add_at_bottom(ss2);
initial.add_at_bottom(ss3);

View File

@ -378,7 +378,7 @@ TextSimulation::update()
ustring temp;
when = h.get_current_time();
smart_ptr<SchedulableList> ll = h.get_simulation_status_at(when);
smart_ptr<SchedulableQueue> ll = h.get_simulation_status_at(when);
for (uint dev=0; dev < _devices.size(); dev++)
{