- Keep a map to hold request queues into a concrete_environment

- TODO: fix test-history consequentially (request queues should be prepared
by Scheduler or by Environment?)


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@793 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-07-23 13:38:13 +00:00
parent 508ce4d86b
commit f26b80f76b
4 changed files with 98 additions and 75 deletions

View file

@ -100,49 +100,21 @@ ConcreteEnvironment::get_resources()
const Environment::Requests
const Environment::SubRequestQueue&
ConcreteEnvironment::get_request_queue(resource_key_t resource_key) const
{
Requests request_queue;
typedef Processes::const_iterator it1_t;
typedef std::vector<Thread*> v2_t;
typedef v2_t::const_iterator it2_t;
typedef std::vector<Request*> v3_t;
typedef v3_t::const_iterator it3_t;
typedef std::vector<SubRequest*> v4_t;
typedef v4_t::const_iterator it4_t;
// Cyclomatic complexity will go nuts here. Feel the love. _ALL_ of it.
for(it1_t it1 = _processes.begin(); it1 != _processes.end(); it1++)
{
const v2_t& threads = (*it1)->get_threads();
for(it2_t it2 = threads.begin(); it2 != threads.end(); it2++)
{
const v3_t& reqs = (*it2)->get_requests();
for(it3_t it3 = reqs.begin(); it3 != reqs.end(); it3++)
{
const v4_t& subr = (*it3)->get_subrequests();
for(it4_t it4 = subr.begin(); it4 != subr.end(); it4++)
{
if((*it4)->get_resource_key() == resource_key)
{
request_queue.push_back(*it3);
break;
}
}
}
}
}
return request_queue;
// Should always return something...
return _sreq_queues.find(resource_key)->second;
}
Environment::SubRequestQueue&
ConcreteEnvironment::get_request_queue(resource_key_t resource_key)
{
// Inserts a new element in none is there!
return _sreq_queues[resource_key];
}
const ReadyQueue&
ConcreteEnvironment::get_sorted_queue() const
@ -175,3 +147,46 @@ ConcreteEnvironment::~ConcreteEnvironment()
// After that, the destructor of _processes is invoked (only invalid pointers)
// After that, the destructor of _resources is invoked (only invalid pointers)
}
// -------------------------------- TO BE FIXED ----------------
// Prepare subrequest list for each resource:
// Requests request_queue;
// typedef Processes::const_iterator it1_t;
// typedef std::vector<Thread*> v2_t;
// typedef v2_t::const_iterator it2_t;
// typedef std::vector<Request*> v3_t;
// typedef v3_t::const_iterator it3_t;
// typedef std::vector<SubRequest*> v4_t;
// typedef v4_t::const_iterator it4_t;
// // Cyclomatic complexity will go nuts here. Feel the love. _ALL_ of it.
// for(it1_t it1 = _processes.begin(); it1 != _processes.end(); it1++)
// {
// const v2_t& threads = (*it1)->get_threads();
// for(it2_t it2 = threads.begin(); it2 != threads.end(); it2++)
// {
// const v3_t& reqs = (*it2)->get_requests();
// for(it3_t it3 = reqs.begin(); it3 != reqs.end(); it3++)
// {
// const v4_t& subr = (*it3)->get_subrequests();
// for(it4_t it4 = subr.begin(); it4 != subr.end(); it4++)
// {
// if((*it4)->get_resource_key() == resource_key)
// {
// request_queue.push_back(*it3);
// break;
// }
// }
// }
// }
// }