- Give code a round of indentation. Thank astyle, not me.

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@837 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-08-09 14:38:45 +00:00
parent aaf8e068d3
commit d3c7b46853
108 changed files with 3196 additions and 3180 deletions

View file

@ -42,82 +42,82 @@ ConcreteEnvironment::ConcreteEnvironment()
ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
Environment(ce), _resources(ce._resources), _processes(), _sched_queue(), _sreq_queues(ce._sreq_queues)
Environment(ce), _resources(ce._resources), _processes(), _sched_queue(), _sreq_queues(ce._sreq_queues)
{
// The ReadyQueue won't be copied. Pointers to objects contained into
// the ready queue _will_ have changed in the new one. The ready queue
// needs to be reset: it is Scheduler that builds it again from time to time.
// The ReadyQueue won't be copied. Pointers to objects contained into
// the ready queue _will_ have changed in the new one. The ready queue
// needs to be reset: it is Scheduler that builds it again from time to time.
// Update resource pointers in a way you won't like :-)
{
for(Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
it->second = new DynamicResource(dynamic_cast<const DynamicResource&>(*it->second));
}
// Update resource pointers in a way you won't like :-)
{
for (Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
it->second = new DynamicResource(dynamic_cast<const DynamicResource&>(*it->second));
}
// DynamicProcess object need to be copied.
// The deep copy is guaranteed by the DynamicProcess copy constructor
{
const Processes& ce_proc = ce._processes;
insert_iterator<Processes> dest(_processes, _processes.begin());
for(Processes::const_iterator orig = ce_proc.begin(); orig != ce_proc.end(); orig++)
*dest++ = new DynamicProcess(dynamic_cast<const DynamicProcess&>(**orig));
}
{
const Processes& ce_proc = ce._processes;
insert_iterator<Processes> dest(_processes, _processes.begin());
for (Processes::const_iterator orig = ce_proc.begin(); orig != ce_proc.end(); orig++)
*dest++ = new DynamicProcess(dynamic_cast<const DynamicProcess&>(**orig));
}
// Update the subrequest queues.
// Update the subrequest queues.
// for each subrequest
typedef Processes::const_iterator it1_t;
// for each subrequest
typedef Processes::const_iterator it1_t;
typedef std::vector<Thread*> v2_t;
typedef v2_t::const_iterator it2_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<Request*> v3_t;
typedef v3_t::const_iterator it3_t;
typedef std::vector<SubRequest*> v4_t;
typedef v4_t::const_iterator it4_t;
typedef std::vector<SubRequest*> v4_t;
typedef v4_t::const_iterator it4_t;
typedef SubRequestQueue::iterator it5_t;
typedef SubRequestQueue::iterator it5_t;
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++)
{
// an optimization here: there is no reason in iterating through
// future or exausted requests. (Do you know why?)
const v4_t& subr = (*it3)->get_subrequests();
for (it4_t it4 = subr.begin(); it4 != subr.end(); it4++)
{
SubRequest::state curr_state = (*it4)->get_state();
if (curr_state != Request::state_future && curr_state != Request::state_exhausted)
{
// the subrequest is the following queue:
SubRequestQueue & queue = get_request_queue((*it4)->get_resource_key());
// we must replace the old pointer:
bool found = false;
for (it5_t it5 = queue.begin(); !found && it5 != queue.end(); it5++)
{
DynamicSubRequest& _old = dynamic_cast<DynamicSubRequest&>(**it5);
DynamicSubRequest& _new = dynamic_cast<DynamicSubRequest&>(**it4);
if (&_old.get_core() == &_new.get_core())
{
found = true;
*it5 = *it4;
}
}
}
}
}
}
}
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++)
{
// an optimization here: there is no reason in iterating through
// future or exausted requests. (Do you know why?)
const v4_t& subr = (*it3)->get_subrequests();
for(it4_t it4 = subr.begin(); it4 != subr.end(); it4++)
{
SubRequest::state curr_state = (*it4)->get_state();
if(curr_state != Request::state_future && curr_state != Request::state_exhausted)
{
// the subrequest is the following queue:
SubRequestQueue & queue = get_request_queue((*it4)->get_resource_key());
// we must replace the old pointer:
bool found = false;
for(it5_t it5 = queue.begin(); !found && it5 != queue.end(); it5++)
{
DynamicSubRequest& _old = dynamic_cast<DynamicSubRequest&>(**it5);
DynamicSubRequest& _new = dynamic_cast<DynamicSubRequest&>(**it4);
if (&_old.get_core() == &_new.get_core())
{
found = true;
*it5 = *it4;
}
}
}
}
}
}
}
}
@ -195,14 +195,14 @@ ConcreteEnvironment::get_sorted_queue()
ConcreteEnvironment::~ConcreteEnvironment()
{
// This call will invoke the DynamicProcess virtual destructor
// Which will delete on cascade all DynamicThreads and so on.
for_each(_processes.begin(), _processes.end(),
memory::deletor<Process>());
// This call will invoke the DynamicProcess virtual destructor
// Which will delete on cascade all DynamicThreads and so on.
for_each(_processes.begin(), _processes.end(),
memory::deletor<Process>());
// We do the same with Resources.
for(Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
delete it->second;
// We do the same with Resources.
for (Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
delete it->second;
// After this, the destructor of _sched_queue is invoked (only invalid pointers)
// After that, the destructor of _processes is invoked (only invalid pointers)