- Added still more error checking to PythonCPUPolicy. But the code which calls its methods should be updated to handle the new exceptions...
- Added a base class for cpu policy exceptions to make simpler their catching - Implemented all numeric fields in dialogs with spinboxes, with bounds checking git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@838 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
d3c7b46853
commit
48fc2f5a00
18 changed files with 298 additions and 177 deletions
|
@ -101,8 +101,18 @@ CPUPoliciesGatekeeper::activate_policy(History *history, CPUPolicy* policy)
|
|||
|
||||
if (pos == end || pos->second != policy)
|
||||
{
|
||||
_active_policies[history] = policy;
|
||||
_active_policies[history]->activate();
|
||||
try
|
||||
{
|
||||
policy->activate();
|
||||
_active_policies[history] = policy;
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
{
|
||||
//FIXME what to do here???
|
||||
//probably throwing again a MalformedPolicyException
|
||||
//maybe the best idea. or can we just fallback
|
||||
//to the previous policy?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "policy_parameters.hh"
|
||||
#include "user_interrupt_exception.hh"
|
||||
#include "malformed_policy_exception.hh"
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
|
@ -50,7 +51,7 @@ namespace sgpem
|
|||
Because it's a pure virtual method, must be re-implemented
|
||||
in concrete derived classes.
|
||||
*/
|
||||
virtual void configure() throw(UserInterruptException) = 0;
|
||||
virtual void configure() throw(UserInterruptException, MalformedPolicyException) = 0;
|
||||
|
||||
/**
|
||||
Sort the \ref ReadyQueue object that contain all the Schedulable objects
|
||||
|
@ -59,7 +60,7 @@ namespace sgpem
|
|||
Because it's a pure virtual method, must be re-implemented
|
||||
in concrete derived classes.
|
||||
*/
|
||||
virtual void sort_queue() const throw(UserInterruptException) = 0;
|
||||
virtual void sort_queue() const throw(UserInterruptException, MalformedPolicyException) = 0;
|
||||
|
||||
/**
|
||||
Gets a string description of the policy.
|
||||
|
@ -79,7 +80,7 @@ namespace sgpem
|
|||
in concrete derived classes.
|
||||
\return True if this policy is preemptible.
|
||||
*/
|
||||
virtual bool is_pre_emptive() const throw(UserInterruptException) = 0;
|
||||
virtual bool is_pre_emptive() const throw(UserInterruptException, MalformedPolicyException) = 0;
|
||||
|
||||
/**
|
||||
Gets the time quantum for the policy.
|
||||
|
@ -88,9 +89,9 @@ namespace sgpem
|
|||
in concrete derived classes.
|
||||
\return Time quantum for the policy.
|
||||
*/
|
||||
virtual int get_time_slice() const throw(UserInterruptException) = 0;
|
||||
virtual int get_time_slice() const throw(UserInterruptException, MalformedPolicyException) = 0;
|
||||
|
||||
virtual void activate() = 0;
|
||||
virtual void activate() throw(UserInterruptException, MalformedPolicyException) = 0;
|
||||
|
||||
virtual void deactivate() = 0;
|
||||
|
||||
|
|
31
src/backend/cpu_policy_exception.cc
Normal file
31
src/backend/cpu_policy_exception.cc
Normal file
|
@ -0,0 +1,31 @@
|
|||
// src/backend/cpu_policy_exception.cc - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
// This file is part of SGPEMv2.
|
||||
//
|
||||
// This is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// SGPEMv2 is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
// Warning! This exception will be thrown across different libraries.
|
||||
// It could be necessary to do dynamic type-checking when
|
||||
// catching it (with typeinfo).
|
||||
|
||||
#include "malformed_policy_exception.hh"
|
||||
using namespace sgpem;
|
||||
|
||||
CPUPolicyException::CPUPolicyException(const std::string& msg)
|
||||
: std::runtime_error(msg)
|
||||
{}
|
||||
|
43
src/backend/cpu_policy_exception.hh
Normal file
43
src/backend/cpu_policy_exception.hh
Normal file
|
@ -0,0 +1,43 @@
|
|||
// src/backend/cpu_policy_exception.hh - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
// This file is part of SGPEMv2.
|
||||
//
|
||||
// This is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// SGPEMv2 is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
// Warning! This exception will be thrown across different libraries.
|
||||
// It could be necessary to do dynamic type-checking when
|
||||
// catching it (with typeinfo).
|
||||
|
||||
#ifndef CPU_POLICY_EXCEPTION
|
||||
#define CPU_POLICY_EXCEPTION 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class CPUPolicyException;
|
||||
|
||||
class SG_DLLEXPORT CPUPolicyException : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit CPUPolicyException(const std::string& msg = "");
|
||||
};
|
||||
} //~ namespace sgpem
|
||||
|
||||
#endif
|
|
@ -25,8 +25,7 @@
|
|||
#include "malformed_policy_exception.hh"
|
||||
using namespace sgpem;
|
||||
|
||||
MalformedPolicyException::MalformedPolicyException(const char* msg)
|
||||
: std::runtime_error(msg)
|
||||
MalformedPolicyException::MalformedPolicyException(const std::string& msg)
|
||||
: CPUPolicyException(msg)
|
||||
{}
|
||||
|
||||
MalformedPolicyException::~MalformedPolicyException() throw() {}
|
||||
|
|
|
@ -27,19 +27,16 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include "cpu_policy_exception.hh"
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class MalformedPolicyException;
|
||||
|
||||
class SG_DLLEXPORT MalformedPolicyException : public std::runtime_error
|
||||
class SG_DLLEXPORT MalformedPolicyException : public CPUPolicyException
|
||||
{
|
||||
public:
|
||||
MalformedPolicyException(const char* msg = "");
|
||||
virtual ~MalformedPolicyException() throw ();
|
||||
|
||||
private:
|
||||
explicit MalformedPolicyException(const std::string& msg = "");
|
||||
};
|
||||
} //~ namespace sgpem
|
||||
|
||||
|
|
|
@ -29,4 +29,3 @@ NullPolicyException::NullPolicyException(const char* msg)
|
|||
: std::runtime_error(msg)
|
||||
{}
|
||||
|
||||
NullPolicyException::~NullPolicyException() throw() {}
|
||||
|
|
|
@ -37,9 +37,6 @@ namespace sgpem
|
|||
{
|
||||
public:
|
||||
NullPolicyException(const char* msg = "");
|
||||
virtual ~NullPolicyException() throw ();
|
||||
|
||||
private:
|
||||
};
|
||||
} //~ namespace sgpem
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
using namespace sgpem;
|
||||
|
||||
UserInterruptException::UserInterruptException(const char* msg)
|
||||
: std::runtime_error(msg)
|
||||
: CPUPolicyException(msg)
|
||||
{}
|
||||
|
||||
UserInterruptException::~UserInterruptException() throw() {}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define USER_INTERRUPT_EXCEPTION 1
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu_policy_exception.hh"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
|
@ -33,13 +34,10 @@ namespace sgpem
|
|||
{
|
||||
class UserInterruptException;
|
||||
|
||||
class SG_DLLEXPORT UserInterruptException : public std::runtime_error
|
||||
class SG_DLLEXPORT UserInterruptException : public CPUPolicyException
|
||||
{
|
||||
public:
|
||||
UserInterruptException(const char* msg = "");
|
||||
virtual ~UserInterruptException() throw ();
|
||||
|
||||
private:
|
||||
explicit UserInterruptException(const char* msg = "");
|
||||
};
|
||||
} //~ namespace sgpem
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue