- Fix bunch of nasty bugs into ConcreteHistory

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1241 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-09-17 17:05:43 +00:00
parent a61b21d94b
commit f3e7ee0393
2 changed files with 25 additions and 7 deletions

View File

@ -397,7 +397,11 @@ ConcreteHistory::add_thread(const Glib::ustring& name,
time_t arrival_time,
prio_t base_priority)
{
DynamicProcess& parent_process = down_cast<DynamicProcess&>(parent);
ConcreteEnvironment::Processes& processes = _snapshots.front()->get_processes();
Process* p = deep_find<Process>(processes, parent);
if(!p) throw std::runtime_error(_("History::add_thread() : Parent process not part of this History"));
DynamicProcess& parent_process = down_cast<DynamicProcess&>(*p);
StaticProcess& parent_core = parent_process.get_core();
StaticThread* core = new StaticThread(name, parent_core, cpu_time, arrival_time, base_priority);
DynamicThread* thread = new DynamicThread(core, &parent_process);
@ -428,14 +432,19 @@ DynamicRequest&
ConcreteHistory::add_request(Thread& owner,
time_t instant)
{
DynamicThread& dyn_owner = down_cast<DynamicThread&>(owner);
ConcreteEnvironment::Processes& processes = _snapshots.front()->get_processes();
Process* p = deep_find(processes, owner.get_process());
if(!p) throw std::runtime_error(_("History::add_request() : Parent process not part of this History"));
Thread* t = deep_find(p->get_threads(), owner);
if(!t) throw std::runtime_error(_("History::add_request() : Parent thread not part of this History"));
DynamicThread& dyn_owner = down_cast<DynamicThread&>(*t);
StaticThread& owner_core = dyn_owner.get_core();
StaticRequest* core = new StaticRequest(&owner_core, instant);
DynamicRequest* req = new DynamicRequest(core, &dyn_owner);
dyn_owner.get_requests().push_back(req);
reset();
return *req;
@ -458,13 +467,20 @@ ConcreteHistory::add_subrequest(Request& request,
resource_key_t resource_key,
time_t duration)
{
DynamicRequest& dyn_request = down_cast<DynamicRequest&>(request);
ConcreteEnvironment::Processes& processes = _snapshots.front()->get_processes();
Process* p = deep_find(processes, request.get_thread().get_process());
if(!p) throw std::runtime_error(_("History::add_subrequest() : Parent process not part of this History"));
Thread* t = deep_find(p->get_threads(), request.get_thread());
if(!t) throw std::runtime_error(_("History::add_subrequest() : Parent thread not part of this History"));
Request* r = deep_find(t->get_requests(), request);
if(!r) throw std::runtime_error(_("History::add_subrequest() : Parent request not part of this History"));
DynamicRequest& dyn_request = down_cast<DynamicRequest&>(*r);
StaticSubRequest* core = new StaticSubRequest(resource_key, duration);
DynamicSubRequest* subreq = new DynamicSubRequest(core, &dyn_request);
dyn_request.get_subrequests().push_back(subreq);
reset();
return *subreq;

View File

@ -20,6 +20,8 @@
#include <sgpemv2/schedulable.hh>
#include <cassert>
using namespace sgpem;
Schedulable::~Schedulable()