- 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

@ -21,19 +21,33 @@
#include "static_thread.hh"
#include "static_request.hh"
#include <algorithm>
#include <cassert>
using namespace sgpem;
using std::vector;
using namespace std;
StaticThread::StaticThread(const Glib::ustring& name,
StaticProcess& process,
unsigned int cpu_time,
unsigned int arrival_time,
int base_priority) :
StaticSchedulable(name, arrival_time, 0, base_priority),
_start_time_delta(arrival_time), _required_cpu_time(0),
StaticSchedulable(name, base_priority),
_start_time_delta(arrival_time),
_required_cpu_time(cpu_time),
_process(&process)
{}
{
process.get_threads().push_back(this);
}
StaticThread::~StaticThread()
{
typedef std::vector<StaticThread*> Threads;
Threads siblings& = _process.get_threads();
siblings.erase(find(siblings.begin(), siblings.end(), this);
}
unsigned int
StaticThread::get_total_cpu_time() const
@ -53,27 +67,8 @@ StaticThread::get_process()
return *_process;
}
void
StaticThread::remove_request(StaticRequest* request)
std::vector<StaticRequest*>&
StaticThread::get_requests()
{
assert(request != NULL);
vector<StaticRequest*>::iterator it;
it = std::find(_static_requests.begin(), _static_requests.end(), request);
if(it != _static_requests.end())
{
_static_requests.erase(it);
delete *it;
}
return _requests;
}
void
StaticThread::add_request(StaticRequest* request)
{
assert(request != NULL);
_static_requests.push_back(request);
}