- Added Thread class

- Synchronized DynamicSchedulable and DynamicProcess with changes in design

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@637 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-06-19 22:37:27 +00:00
parent 30d070a420
commit ec7c6a7c81
8 changed files with 148 additions and 61 deletions

View file

@ -21,11 +21,13 @@
#include "dynamic_process.hh"
#include "static_process.hh"
#include <cassert>
using namespace sgpem;
using std::vector;
DynamicProcess::DynamicProcess(StaticProcess& core) :
DynamicSchedulable(core)
DynamicProcess::DynamicProcess(StaticProcess* core) :
DynamicSchedulable(*core)
{
}
@ -34,6 +36,8 @@ DynamicProcess::DynamicProcess(const DynamicProcess &other) :
{
typedef vector<DynamicThread*>::iterator ThreadIt;
_static_process = other._static_process;
const vector<DynamicThread*>& other_threads = other._dynamic_threads;
// FIXME uncomment when DynamicThread is complete
@ -41,26 +45,47 @@ DynamicProcess::DynamicProcess(const DynamicProcess &other) :
// _dynamic_threads.push_back(new DynamicThread(*(*it)));
}
std::vector<Thread*> DynamicProcess::get_threads()
std::vector<Thread*>
DynamicProcess::get_threads()
{
//FIXME uncomment when DynamicThread is complete
//return vector<Thread*>(_dynamic_threads.begin(), _dynamic_threads.end());
return vector<Thread*>();
}
//FIXME already implemented in DynamicSchedulable
//state get_state() const
//{
Schedulable::state
DynamicProcess::get_state() const
{
// //TODO complicated code here! leave me some time to figure
// // out what I need to do inside this method
//}
std::vector<DynamicThread*> DynamicProcess::get_dynamic_threads()
{
return _dynamic_threads;
return DynamicSchedulable::get_state();
}
void DynamicProcess::serialize(SerializeVisitor& translator)
void
DynamicProcess::remove_thread(Thread* thread)
{
assert(thread != NULL);
//FIXME uncomment me once DynamicThread is complete
//vector<DynamicThread*>::iterator it;
//it = std::find(_dynamic_threads.begin(), _dynamic_threads.end(), thread);
//FIXME Do I need to deallocate the associated memory?
//if(it != _dynamic_threads.end())
// _dynamic_threads.erase(it);
}
void
DynamicProcess::add_thread(DynamicThread* thread)
{
assert(thread != NULL);
_dynamic_threads.push_back(thread);
}
void
DynamicProcess::serialize(SerializeVisitor& translator) const
{
//FIXME write this code. I'm predictable, I know
}