- Mega-update. Take it while it's hot... but my brain's frying!

- Fixed all Dynamic and Static entities lacking proper destructors:
Dynamic entities need to delete Dynamic children, Static entities
need only to delete them from the list of their siblings
- Added methods to get Static "core" from Dynamic*.
- Now get_core() is a pure virtual function into DynamicSchedulable.
A quite nice solution(?), really, if I can say that myself... ;-)
- ConcreteHistory is half-implemented. It's the other half that 
worries me.
- TODO: finish off ConcreteHistory, and check that things get destroyed
properly (no leaks allowed, use valgrind).
- TODO: rework Simulation
- TODO: Scheduler rewrite
- *A side note*: this code is becoming a mess. I prefer references over
pointers, but someone other prefer pointers over references, and what
happens is that you've to continously pass from one to another when
invoking other methods... this is bad.


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@694 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-07-02 22:20:03 +00:00
parent 787d24964b
commit 7d62f4b937
25 changed files with 564 additions and 321 deletions

View file

@ -23,13 +23,14 @@
#include "dynamic_thread.hh"
#include <algorithm>
#include <functional>
#include <cassert>
using namespace sgpem;
using std::vector;
using namespace std;
DynamicProcess::DynamicProcess(StaticProcess* core) :
DynamicSchedulable(*core)
DynamicProcess::DynamicProcess(StaticProcess* core)
: DynamicSchedulable(), _core(core)
{}
DynamicProcess::DynamicProcess(const DynamicProcess &other) :
@ -43,6 +44,11 @@ DynamicProcess::DynamicProcess(const DynamicProcess &other) :
_dynamic_threads.push_back(new DynamicThread(*(*it)));
}
DynamicProcess::~DynamicProcess()
{
for_each(_dynamic_threads.begin(), _dynamic_threads.end(), ptr_fun(operator delete));
}
std::vector<Thread*>
DynamicProcess::get_threads()
@ -123,32 +129,6 @@ DynamicProcess::get_state() const
return result;
}
void
DynamicProcess::remove_thread(Thread* thread)
{
assert(thread != NULL);
vector<DynamicThread*>::iterator it;
it = std::find(_dynamic_threads.begin(), _dynamic_threads.end(), thread);
if(it != _dynamic_threads.end())
{
_dynamic_threads.erase(it);
// FIXME remove me and leave the responsibility for deletion to the caller
// (which is?)
delete *it;
}
}
void
DynamicProcess::add_thread(DynamicThread* thread)
{
assert(thread != NULL);
_dynamic_threads.push_back(thread);
}
void
DynamicProcess::serialize(SerializeVisitor& translator) const
@ -156,3 +136,22 @@ DynamicProcess::serialize(SerializeVisitor& translator) const
//FIXME write this code. I'm predictable, I know
}
StaticProcess&
DynamicProcess::get_core()
{
return *_core;
}
const StaticProcess&
DynamicProcess::get_core() const
{
return *_core;
}
std::vector<DynamicThread*>&
DynamicProcess::get_dynamic_threads()
{
return _dynamic_threads;
}