- Fix the st8ad_cast bug. Please report it has been fixed

with this revision number into the anomaly records.


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1200 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-09-16 16:59:59 +00:00
parent 961bcf6dc6
commit 4ff9985ad5
5 changed files with 32 additions and 45 deletions

View File

@ -146,8 +146,6 @@ ConcreteHistory::remove(resource_key_t resource_key)
if (found == resources.end())
return;
reset(false);
delete found->second;
resources.erase(found);
@ -195,7 +193,7 @@ ConcreteHistory::remove(resource_key_t resource_key)
// for example. Or hangovers. Or being read poetry by a Vogon.
// Although the above construct really rates between the first tens.
notify_change();
reset();
}
@ -207,7 +205,7 @@ ConcreteHistory::remove(Process& process)
ConcreteEnvironment::Processes& processes = initial.get_processes();
bool found = deep_remove<Process>(processes, process);
if (found)
reset(true);
reset();
}
@ -229,7 +227,7 @@ ConcreteHistory::remove(Thread& thread)
bool removed = deep_remove<DynamicThread>(dynamic_found.get_dynamic_threads(), dyn_thr);
if (removed)
reset(true);
reset();
}
@ -255,7 +253,7 @@ ConcreteHistory::remove(Request& request)
bool removed = deep_remove<DynamicRequest>(thr_ref->get_dynamic_requests(), dyn_req);
if (removed)
reset(true);
reset();
}
@ -288,18 +286,16 @@ ConcreteHistory::remove(SubRequest& subrequest)
bool removed = deep_remove<DynamicSubRequest>(req_ref->get_dynamic_subrequests(), dyn_sub);
if (removed)
reset(true);
reset();
}
void
ConcreteHistory::clear()
{
reset(false);
assert(_snapshots.size() == 1);
delete _snapshots.front();
_snapshots.front() = new ConcreteEnvironment();
notify_change();
reset();
}
@ -309,8 +305,6 @@ ConcreteHistory::add_resource(const Glib::ustring& name,
size_t places,
size_t availability)
{
reset(false);
typedef ConcreteEnvironment::Resources Resources;
typedef ConcreteEnvironment::SubRequestQueue SubRequestQueue;
// And preemptable and availability?? FIXME!
@ -332,8 +326,7 @@ ConcreteHistory::add_resource(const Glib::ustring& name,
SubRequestQueue emptysrq;
_snapshots.front()->get_subrequest_queues().insert(pair<resource_key_t, SubRequestQueue>(index, emptysrq));
notify_change();
reset();
return *temp;
}
@ -353,7 +346,7 @@ ConcreteHistory::edit_resource(Resource& resource,
core.set_name(name);
core.set_places(places);
reset(true);
reset();
}
@ -362,15 +355,14 @@ ConcreteHistory::add_process(const Glib::ustring& name,
time_t arrival_time,
prio_t base_priority)
{
reset(false);
StaticProcess* core = new StaticProcess(name, arrival_time, base_priority);
DynamicProcess* proc = new DynamicProcess(core);
ConcreteEnvironment::Processes& processes = _snapshots.front()->get_processes();
processes.push_back(proc);
notify_change();
reset();
return *proc;
}
@ -387,7 +379,7 @@ ConcreteHistory::edit_process(Process& process,
core.set_arrival_time(arrival_time);
core.set_priority(base_priority);
reset(true);
reset();
}
@ -399,14 +391,13 @@ ConcreteHistory::add_thread(const Glib::ustring& name,
time_t arrival_time,
prio_t base_priority)
{
reset(false);
DynamicProcess& parent_process = down_cast<DynamicProcess&>(parent);
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);
notify_change();
reset();
return *thread;
}
@ -424,15 +415,13 @@ ConcreteHistory::edit_thread(Thread& thread,
core.set_arrival_time(arrival_time);
core.set_priority(base_priority);
reset(true);
reset();
}
DynamicRequest&
ConcreteHistory::add_request(Thread& owner,
time_t instant)
{
reset(false);
DynamicThread& dyn_owner = down_cast<DynamicThread&>(owner);
StaticThread& owner_core = dyn_owner.get_core();
@ -441,7 +430,8 @@ ConcreteHistory::add_request(Thread& owner,
dyn_owner.get_requests().push_back(req);
notify_change();
reset();
return *req;
}
@ -453,7 +443,7 @@ ConcreteHistory::edit_request(Request& request,
StaticRequest& core = req->get_core();
core.set_instant(instant);
reset(true);
reset();
}
@ -462,8 +452,6 @@ ConcreteHistory::add_subrequest(Request& request,
resource_key_t resource_key,
time_t duration)
{
reset(false);
DynamicRequest& dyn_request = down_cast<DynamicRequest&>(request);
StaticSubRequest* core = new StaticSubRequest(resource_key, duration);
@ -471,7 +459,8 @@ ConcreteHistory::add_subrequest(Request& request,
dyn_request.get_subrequests().push_back(subreq);
notify_change();
reset();
return *subreq;
}
@ -485,14 +474,7 @@ ConcreteHistory::edit_subrequest(SubRequest& subrequest,
core.set_resource_key(resource_key);
core.set_length(duration);
reset(true);
}
void
ConcreteHistory::reset()
{
reset(true);
reset();
}
@ -509,9 +491,15 @@ ConcreteHistory::set_front(position p)
notify_change();
}
void
ConcreteHistory::reset(bool notify)
ConcreteHistory::reset()
{
#ifndef NDEBUG
static unsigned int n = 0;
std::cerr << "ConcreteHistory::reset() called for the " << ++n << "-th time." << std::endl;
#endif
assert(_snapshots.size() > 0);
Snapshots::iterator it = _snapshots.begin();
it++; // Skip first environment that we saved
@ -521,8 +509,7 @@ ConcreteHistory::reset(bool notify)
_front = 0;
_sealed = false;
if (notify)
notify_change();
notify_change();
}

View File

@ -118,7 +118,6 @@ namespace sgpem
bool seal();
void reset(); // Implements a virtual method
void reset(bool notify); // Only available in this class
protected:
typedef std::vector<ConcreteEnvironment*> Snapshots;

View File

@ -124,7 +124,7 @@ CPUPoliciesGatekeeper::activate_policy(History *history, CPUPolicy* policy) thro
policy->activate();
_active_policies[history] = policy;
// the content of history (if any) is not vaild any more.
down_cast<ConcreteHistory*>(history)->reset(true);
down_cast<ConcreteHistory*>(history)->reset();
}
catch(const CPUPolicyException& e)
{

View File

@ -98,7 +98,7 @@ ResourcePoliciesGatekeeper::activate_policy(History *history, ResourcePolicy* po
_active_policies[history] = policy;
// the content of history (if any) is not vaild any more.
down_cast<ConcreteHistory*>(history)->reset(true);
down_cast<ConcreteHistory*>(history)->reset();
}
ResourcePoliciesGatekeeper::ResourcePoliciesGatekeeper()

View File

@ -19,13 +19,14 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/*
// DISCLAIMER FOR THE RAMPANT CODER: \\
// ----------------------------------------------------\\
// ``If you touch this code, your ass is grass, \\
// and I'm the lawnmover.'' \\
// -- David Cutler \\
// ----------------------------------------------------\\
*/
#include "concrete_environment.hh"
#include "concrete_history.hh"