- Fix CPUPolicy.get_parameters() in Python with a simple yet effective hack

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@835 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-08-09 14:01:46 +00:00
parent 86308ca185
commit 3968bc7cbd
2 changed files with 15 additions and 3 deletions

View File

@ -97,7 +97,7 @@ class CPUPolicy:
#
# @return A sgpem::PolicyParameters instance
def get_parameters(self):
return sgpem.Scheduler.get_instance().get_policy().get_parameters()
return sgpem.CPUPolicy.get_active_policy().get_parameters()
## @brief This function implements an in-place stable sort

View File

@ -1,11 +1,14 @@
%module sgpem
%{
#include "cpu_policy.hh"
#include "cpu_policies_gatekeeper.hh"
#include "history.hh"
#include "policy_parameters.hh"
#include "process.hh"
#include "ready_queue.hh"
#include "schedulable.hh"
#include "scheduler.hh"
#include "simulation.hh"
#include "thread.hh"
%}
@ -58,11 +61,20 @@ namespace std
// ------------- DECLARATIONS -------------------------------
namespace sgpem {
class CPUPolicy {
public:
virtual ~CPUPolicy() = 0;
sgpem::PolicyParameters& get_parameters();
%extend {
// Convenience function to get the current policy
static CPUPolicy* get_active_policy()
{
History& h = Simulation::get_instance().get_history();
return CPUPoliciesGatekeeper::get_instance().get_current_policy(&h);
};
}
};
// --------------------------------------------
@ -218,9 +230,9 @@ namespace sgpem {
}; //~ class ReadyQueue
// ---------------------------------------------
class Scheduler {
public:
sgpem::CPUPolicy* get_policy();
static sgpem::Scheduler& get_instance();
sgpem::ReadyQueue* get_ready_queue();
private: