sgpemv2/src/backend/resource_policy_lifo.cc
tchernobog 99135b1237 Fix compilation warnings and a couple of errors due to GCC -pedantic flags
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1329 3ecf2c5c-341e-0410-92b4-d18e462d057c
2008-11-08 21:17:11 +00:00

97 lines
2.3 KiB
C++

// src/backend/resource_policy_lifo.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2. If not, see http://www.gnu.org/licenses/.
#include "resource_policy_lifo.hh"
using namespace std;
using namespace sgpem;
ResourcePolicyLiFo::~ResourcePolicyLiFo()
{}
void
ResourcePolicyLiFo::configure()
throw(UserInterruptException)
{
}
void
ResourcePolicyLiFo::enforce(Environment& /*environment*/, Environment::SubRequestQueue& queue, SubRequest& sr)
throw(UserInterruptException)
{
typedef Environment::SubRequestQueue SubRequestQueue;
// the last inserted request goes on the first free place.
SubRequestQueue old_queue(queue);
queue.clear();
typedef SubRequestQueue::iterator It;
for (It i = old_queue.begin(); i != old_queue.end(); i++)
{
// allocated ones remain allocated
if((**i).get_state() == Request::state_allocated)
queue.push_back(*i);
}
bool inserted = false;
typedef SubRequestQueue::iterator It;
for (It i = old_queue.begin(); i != old_queue.end(); i++)
{
// allocated ones remain allocated
if((**i).get_state() != Request::state_allocated)
{
// non-allocated ones go after the newly arrived
if(!inserted)
{
queue.push_back(&sr);
inserted = true;
}
if (*i != &sr)
queue.push_back(*i);
}
}
}
Glib::ustring
ResourcePolicyLiFo::get_description() const
{
return _("A resource policy which allows a request to be immediately allocated if there is enough space.");
}
Glib::ustring
ResourcePolicyLiFo::get_name() const
{
return _("Last In, First Out");
}
void
ResourcePolicyLiFo::activate()
{
}
void
ResourcePolicyLiFo::deactivate()
{
}