- Adjusted copy construction of the Dynamic* hierarchy. Hope this is what you wanted, Matteo...
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@751 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
b6b303c4e3
commit
8ffd81b823
|
@ -30,9 +30,11 @@
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
DynamicProcess::DynamicProcess(StaticProcess* core)
|
DynamicProcess::DynamicProcess(StaticProcess* core) :
|
||||||
: DynamicSchedulable(), _core(core)
|
DynamicSchedulable(), _core(core)
|
||||||
{}
|
{
|
||||||
|
assert(core != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
DynamicProcess::DynamicProcess(const DynamicProcess &other) :
|
DynamicProcess::DynamicProcess(const DynamicProcess &other) :
|
||||||
Schedulable(), DynamicSchedulable(other), Process()
|
Schedulable(), DynamicSchedulable(other), Process()
|
||||||
|
@ -42,7 +44,7 @@ DynamicProcess::DynamicProcess(const DynamicProcess &other) :
|
||||||
const vector<DynamicThread*>& other_threads = other._dynamic_threads;
|
const vector<DynamicThread*>& other_threads = other._dynamic_threads;
|
||||||
|
|
||||||
for(ThreadIt it = other_threads.begin(); it != other_threads.end(); ++it)
|
for(ThreadIt it = other_threads.begin(); it != other_threads.end(); ++it)
|
||||||
_dynamic_threads.push_back(new DynamicThread(*(*it)));
|
new DynamicThread(*(*it), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicProcess::~DynamicProcess()
|
DynamicProcess::~DynamicProcess()
|
||||||
|
@ -50,7 +52,6 @@ DynamicProcess::~DynamicProcess()
|
||||||
for_each(_dynamic_threads.begin(), _dynamic_threads.end(), ptr_fun(operator delete));
|
for_each(_dynamic_threads.begin(), _dynamic_threads.end(), ptr_fun(operator delete));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<Thread*>
|
std::vector<Thread*>
|
||||||
DynamicProcess::get_threads()
|
DynamicProcess::get_threads()
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,28 @@ DynamicRequest::DynamicRequest(StaticRequest *core,
|
||||||
siblings.push_back(this);
|
siblings.push_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DynamicRequest::DynamicRequest(const DynamicRequest& other, DynamicThread* owner) :
|
||||||
|
_static_request(other._static_request), _dynamic_thread(owner),
|
||||||
|
_state(other._state)
|
||||||
|
{
|
||||||
|
typedef vector<DynamicSubRequest*> SubReqVec;
|
||||||
|
|
||||||
|
assert(owner != NULL);
|
||||||
|
|
||||||
|
const SubReqVec& other_subs = other._dynamic_subrequests;
|
||||||
|
|
||||||
|
// Not sure of this, but the constructor of DynamicSubRequest should take care
|
||||||
|
// of adding itself to the vector of sub requests. This is only my opinion,
|
||||||
|
// but I think this is a complicated way of doing things...
|
||||||
|
for(SubReqVec::const_iterator it = other_subs.begin(); it != other_subs.end(); ++it)
|
||||||
|
new DynamicSubRequest(*(*it), this);
|
||||||
|
|
||||||
|
// Leave this line: it helps us with a compiler warning if
|
||||||
|
// the get_dynamic* method signature changes:
|
||||||
|
std::vector<DynamicRequest*>& siblings = owner->get_dynamic_requests();
|
||||||
|
siblings.push_back(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicRequest::~DynamicRequest()
|
DynamicRequest::~DynamicRequest()
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace sgpem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DynamicRequest(StaticRequest *core, DynamicThread* owner);
|
DynamicRequest(StaticRequest *core, DynamicThread* owner);
|
||||||
|
DynamicRequest(const DynamicRequest& other, DynamicThread* owner);
|
||||||
~DynamicRequest();
|
~DynamicRequest();
|
||||||
|
|
||||||
virtual bool operator==(const Request& op2) const;
|
virtual bool operator==(const Request& op2) const;
|
||||||
|
@ -66,6 +67,9 @@ namespace sgpem
|
||||||
std::vector<DynamicSubRequest*>& get_dynamic_subrequests();
|
std::vector<DynamicSubRequest*>& get_dynamic_subrequests();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Undefined
|
||||||
|
DynamicRequest(const DynamicRequest& other);
|
||||||
|
|
||||||
memory::smart_ptr<StaticRequest> _static_request;
|
memory::smart_ptr<StaticRequest> _static_request;
|
||||||
DynamicThread* _dynamic_thread;
|
DynamicThread* _dynamic_thread;
|
||||||
state _state;
|
state _state;
|
||||||
|
|
|
@ -35,12 +35,25 @@ DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,
|
||||||
_queue_position(-1)
|
_queue_position(-1)
|
||||||
{
|
{
|
||||||
assert(core != NULL);
|
assert(core != NULL);
|
||||||
|
assert(owner != NULL);
|
||||||
// Leave this line: it helps us with a compiler warning if
|
// Leave this line: it helps us with a compiler warning if
|
||||||
// the get_dynamic* method signature changes:
|
// the get_dynamic* method signature changes:
|
||||||
std::vector<DynamicSubRequest*>& siblings = owner->get_dynamic_subrequests();
|
std::vector<DynamicSubRequest*>& siblings = owner->get_dynamic_subrequests();
|
||||||
siblings.push_back(this);
|
siblings.push_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DynamicSubRequest::DynamicSubRequest(const DynamicSubRequest& other,
|
||||||
|
DynamicRequest* owner) :
|
||||||
|
_static_subrequest(other._static_subrequest), _owner(owner),
|
||||||
|
_queue_position(other._queue_position)
|
||||||
|
{
|
||||||
|
assert(owner != NULL);
|
||||||
|
|
||||||
|
// Leave this line: it helps us with a compiler warning if
|
||||||
|
// the get_dynamic* method signature changes:
|
||||||
|
std::vector<DynamicSubRequest*>& siblings = owner->get_dynamic_subrequests();
|
||||||
|
siblings.push_back(this);
|
||||||
|
}
|
||||||
|
|
||||||
DynamicSubRequest::~DynamicSubRequest()
|
DynamicSubRequest::~DynamicSubRequest()
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace sgpem
|
||||||
public:
|
public:
|
||||||
DynamicSubRequest(StaticSubRequest* core,
|
DynamicSubRequest(StaticSubRequest* core,
|
||||||
DynamicRequest* owner);
|
DynamicRequest* owner);
|
||||||
|
DynamicSubRequest(const DynamicSubRequest& other, DynamicRequest* owner);
|
||||||
|
|
||||||
virtual ~DynamicSubRequest();
|
virtual ~DynamicSubRequest();
|
||||||
|
|
||||||
|
@ -63,6 +64,9 @@ namespace sgpem
|
||||||
const StaticSubRequest& get_core() const;
|
const StaticSubRequest& get_core() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Undefined
|
||||||
|
DynamicSubRequest(const DynamicSubRequest&);
|
||||||
|
|
||||||
memory::smart_ptr<StaticSubRequest> _static_subrequest;
|
memory::smart_ptr<StaticSubRequest> _static_subrequest;
|
||||||
DynamicRequest* _owner;
|
DynamicRequest* _owner;
|
||||||
int _queue_position;
|
int _queue_position;
|
||||||
|
|
|
@ -37,24 +37,33 @@ DynamicThread::DynamicThread(StaticThread* core, DynamicProcess* parent)
|
||||||
: DynamicSchedulable(), _core(core), _state(state_future), _parent(parent),
|
: DynamicSchedulable(), _core(core), _state(state_future), _parent(parent),
|
||||||
_ran_for(0), _last_acquisition(-1), _last_release(-1)
|
_ran_for(0), _last_acquisition(-1), _last_release(-1)
|
||||||
{
|
{
|
||||||
|
assert(core != NULL);
|
||||||
|
assert(parent != NULL);
|
||||||
|
|
||||||
// Leave this line: it helps us with a compiler warning if
|
// Leave this line: it helps us with a compiler warning if
|
||||||
// the get_dynamic* method signature changes:
|
// the get_dynamic* method signature changes:
|
||||||
std::vector<DynamicThread*>& siblings = parent->get_dynamic_threads();
|
std::vector<DynamicThread*>& siblings = parent->get_dynamic_threads();
|
||||||
siblings.push_back(this);
|
siblings.push_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicThread::DynamicThread(const DynamicThread &other) :
|
DynamicThread::DynamicThread(const DynamicThread &other, DynamicProcess* parent) :
|
||||||
Schedulable(), DynamicSchedulable(other), Thread()
|
Schedulable(), DynamicSchedulable(other), Thread(),
|
||||||
|
_state(other._state), _parent(parent), _ran_for(other._ran_for),
|
||||||
|
_last_acquisition(other._last_acquisition), _last_release(other._last_release)
|
||||||
{
|
{
|
||||||
typedef vector<DynamicRequest*>::const_iterator ReqIt;
|
typedef vector<DynamicRequest*>::const_iterator ReqIt;
|
||||||
|
|
||||||
|
assert(parent != NULL);
|
||||||
|
|
||||||
const vector<DynamicRequest*>& other_req = other._dynamic_requests;
|
const vector<DynamicRequest*>& other_req = other._dynamic_requests;
|
||||||
|
|
||||||
_state = other._state;
|
|
||||||
_parent = other._parent;
|
|
||||||
|
|
||||||
for(ReqIt it = other_req.begin(); it != other_req.end(); ++it)
|
for(ReqIt it = other_req.begin(); it != other_req.end(); ++it)
|
||||||
_dynamic_requests.push_back(new DynamicRequest(*(*it)));
|
new DynamicRequest(*(*it), this);
|
||||||
|
|
||||||
|
// Leave this line: it helps us with a compiler warning if
|
||||||
|
// the get_dynamic* method signature changes:
|
||||||
|
std::vector<DynamicThread*>& siblings = parent->get_dynamic_threads();
|
||||||
|
siblings.push_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicThread::~DynamicThread()
|
DynamicThread::~DynamicThread()
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace sgpem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DynamicThread(StaticThread* core, DynamicProcess* parent);
|
DynamicThread(StaticThread* core, DynamicProcess* parent);
|
||||||
DynamicThread(const DynamicThread &other);
|
DynamicThread(const DynamicThread &other, DynamicProcess* parent);
|
||||||
virtual ~DynamicThread();
|
virtual ~DynamicThread();
|
||||||
|
|
||||||
DynamicProcess& get_process();
|
DynamicProcess& get_process();
|
||||||
|
@ -72,6 +72,9 @@ namespace sgpem
|
||||||
std::vector<DynamicRequest*>& get_dynamic_requests();
|
std::vector<DynamicRequest*>& get_dynamic_requests();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Undefined
|
||||||
|
DynamicThread(const DynamicThread &other);
|
||||||
|
|
||||||
memory::smart_ptr<StaticThread> _core;
|
memory::smart_ptr<StaticThread> _core;
|
||||||
state _state;
|
state _state;
|
||||||
std::vector<DynamicRequest*> _dynamic_requests;
|
std::vector<DynamicRequest*> _dynamic_requests;
|
||||||
|
|
Loading…
Reference in New Issue