From 972db124e678ce6ef6d28014e1c3aa08dfcf4bed Mon Sep 17 00:00:00 2001 From: tchernobog Date: Sun, 17 Sep 2006 19:59:41 +0000 Subject: [PATCH] - Don't expose unnecessary interface - Do a bit of auditing git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1250 3ecf2c5c-341e-0410-92b4-d18e462d057c --- Makefile.am | 10 +- src/backend/cpp_resource_policy_manager.cc | 11 ++- .../cpp_resource_policy_manager.hh | 5 +- src/backend/resource_policy_fifo.cc | 8 +- .../{sgpemv2 => }/resource_policy_fifo.hh | 23 ++--- src/backend/resource_policy_lifo.cc | 9 +- src/backend/resource_policy_lifo.hh | 87 ++++++++++++++++ src/backend/resource_policy_priority.cc | 10 +- ...cy_lifo.hh => resource_policy_priority.hh} | 37 +++---- .../resource_policy_priority_inheritance.cc | 10 +- .../resource_policy_priority_inheritance.hh | 14 +-- src/backend/sgpemv2/null_policy_exception.hh | 7 +- .../sgpemv2/resource_policy_priority.hh | 99 ------------------- 13 files changed, 132 insertions(+), 198 deletions(-) rename src/backend/{sgpemv2 => }/cpp_resource_policy_manager.hh (93%) rename src/backend/{sgpemv2 => }/resource_policy_fifo.hh (83%) create mode 100644 src/backend/resource_policy_lifo.hh rename src/backend/{sgpemv2/resource_policy_lifo.hh => resource_policy_priority.hh} (72%) rename src/backend/{sgpemv2 => }/resource_policy_priority_inheritance.hh (85%) delete mode 100644 src/backend/sgpemv2/resource_policy_priority.hh diff --git a/Makefile.am b/Makefile.am index 6169596..550c886 100644 --- a/Makefile.am +++ b/Makefile.am @@ -268,7 +268,6 @@ src_backend_libbackend_la_SOURCES = \ # Please note that the first listed header is generated by # configure. pkginclude_HEADERS += \ - src/backend/sgpemv2/cpp_resource_policy_manager.hh \ src/backend/sgpemv2/cpu_policies_gatekeeper.hh \ src/backend/sgpemv2/cpu_policy.hh \ src/backend/sgpemv2/cpu_policy_exception.hh \ @@ -291,11 +290,7 @@ pkginclude_HEADERS += \ src/backend/sgpemv2/resource.hh \ src/backend/sgpemv2/resource_policies_gatekeeper.hh \ src/backend/sgpemv2/resource_policy.hh \ - src/backend/sgpemv2/resource_policy_fifo.hh \ - src/backend/sgpemv2/resource_policy_lifo.hh \ src/backend/sgpemv2/resource_policy_manager.hh \ - src/backend/sgpemv2/resource_policy_priority.hh \ - src/backend/sgpemv2/resource_policy_priority_inheritance.hh \ src/backend/sgpemv2/process.hh \ src/backend/sgpemv2/schedulable.hh \ src/backend/sgpemv2/schedulable_statistics.hh \ @@ -319,6 +314,7 @@ pkginclude_HEADERS += \ # Put here headers used internally by the backend # They won't be installed for the end-user. noinst_HEADERS += \ + src/backend/cpp_resource_policy_manager.hh \ src/backend/concrete_environment.hh \ src/backend/concrete_history.hh \ src/backend/concrete_process_statistics.hh \ @@ -332,6 +328,10 @@ noinst_HEADERS += \ src/backend/dynamic_schedulable.hh \ src/backend/dynamic_sub_request.hh \ src/backend/dynamic_thread.hh \ + src/backend/resource_policy_fifo.hh \ + src/backend/resource_policy_lifo.hh \ + src/backend/resource_policy_priority.hh \ + src/backend/resource_policy_priority_inheritance.hh \ src/backend/static_process.hh \ src/backend/static_request.hh \ src/backend/static_resource.hh \ diff --git a/src/backend/cpp_resource_policy_manager.cc b/src/backend/cpp_resource_policy_manager.cc index ea315f7..d118ac4 100644 --- a/src/backend/cpp_resource_policy_manager.cc +++ b/src/backend/cpp_resource_policy_manager.cc @@ -19,11 +19,12 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#include -#include -#include -#include -#include +#include "cpp_resource_policy_manager.hh" +#include "resource_policy_lifo.hh" +#include "resource_policy_fifo.hh" +#include "resource_policy_priority.hh" +#include "resource_policy_priority_inheritance.hh" + #include using namespace sgpem; diff --git a/src/backend/sgpemv2/cpp_resource_policy_manager.hh b/src/backend/cpp_resource_policy_manager.hh similarity index 93% rename from src/backend/sgpemv2/cpp_resource_policy_manager.hh rename to src/backend/cpp_resource_policy_manager.hh index 2514f50..1661e9f 100644 --- a/src/backend/sgpemv2/cpp_resource_policy_manager.hh +++ b/src/backend/cpp_resource_policy_manager.hh @@ -26,13 +26,10 @@ namespace sgpem class ResourcePolicy; } -#include - #include #include - namespace sgpem { class CppResourcePolicyManager; @@ -40,7 +37,7 @@ namespace sgpem /** ResourcePolicyManager is the Abstract Factory for \ref ResourcePolicy objects. */ - class SG_DLLEXPORT CppResourcePolicyManager : public ResourcePolicyManager + class CppResourcePolicyManager : public ResourcePolicyManager { public: /** \brief CppResourcePolicyManager constructor diff --git a/src/backend/resource_policy_fifo.cc b/src/backend/resource_policy_fifo.cc index b382cfd..5bdd553 100644 --- a/src/backend/resource_policy_fifo.cc +++ b/src/backend/resource_policy_fifo.cc @@ -18,7 +18,7 @@ // along with SGPEMv2; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#include +#include "resource_policy_fifo.hh" using namespace std; @@ -28,12 +28,6 @@ ResourcePolicyFiFo::~ResourcePolicyFiFo() {} -PolicyParameters& -ResourcePolicyFiFo::get_parameters() -{ - return _parameters; -} - void ResourcePolicyFiFo::configure() throw(UserInterruptException) diff --git a/src/backend/sgpemv2/resource_policy_fifo.hh b/src/backend/resource_policy_fifo.hh similarity index 83% rename from src/backend/sgpemv2/resource_policy_fifo.hh rename to src/backend/resource_policy_fifo.hh index c3237dd..ae37d28 100644 --- a/src/backend/sgpemv2/resource_policy_fifo.hh +++ b/src/backend/resource_policy_fifo.hh @@ -1,4 +1,4 @@ -// src/backend/sgpemv2/resource_policy_fifo.hh - Copyright 2005, 2006, University +// src/backend/resource_policy_fifo.hh - Copyright 2005, 2006, University // of Padova, dept. of Pure and Applied // Mathematics // @@ -21,7 +21,12 @@ #ifndef RESOURCE_POLICY_FIFO_HH #define RESOURCE_POLICY_FIFO_HH 1 +#include "gettext.h" + +#include + #include +#include namespace sgpem { @@ -31,13 +36,9 @@ namespace sgpem It's a Strategy wich stay for a resource allocating algorithm. It implements the related resource allocation policy. */ - class SG_DLLEXPORT ResourcePolicyFiFo : public ResourcePolicy + class ResourcePolicyFiFo : public ResourcePolicy { public: - - /// \brief Standard virtual destructor. - /// - /// Standard virtual destructor. virtual ~ResourcePolicyFiFo(); /** @@ -70,16 +71,6 @@ namespace sgpem virtual void activate(); virtual void deactivate(); - - /** - Gets the parameters related with this policy. - - \return The policy parameters. - */ - PolicyParameters& get_parameters(); - - protected: - PolicyParameters _parameters; }; }//~ namespace sgpem diff --git a/src/backend/resource_policy_lifo.cc b/src/backend/resource_policy_lifo.cc index c9e3208..a75b463 100644 --- a/src/backend/resource_policy_lifo.cc +++ b/src/backend/resource_policy_lifo.cc @@ -18,8 +18,7 @@ // along with SGPEMv2; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#include - +#include "resource_policy_lifo.hh" using namespace std; using namespace sgpem; @@ -28,12 +27,6 @@ ResourcePolicyLiFo::~ResourcePolicyLiFo() {} -PolicyParameters& -ResourcePolicyLiFo::get_parameters() -{ - return _parameters; -} - void ResourcePolicyLiFo::configure() throw(UserInterruptException) diff --git a/src/backend/resource_policy_lifo.hh b/src/backend/resource_policy_lifo.hh new file mode 100644 index 0000000..f83694c --- /dev/null +++ b/src/backend/resource_policy_lifo.hh @@ -0,0 +1,87 @@ +// src/backend/resource_policy_lifo.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 + +#ifndef RESOURCE_POLICY_LIFO_HH +#define RESOURCE_POLICY_LIFO_HH 1 + +#include "gettext.h" + +#include +#include +#include + +#include + +namespace sgpem +{ + class ResourcePolicyLiFo; + + /** \brief + It's a Strategy wich stay for a resource allocating algorithm. + It implements the related resource allocation policy. + */ + class ResourcePolicyLiFo : public ResourcePolicy + { + public: + virtual ~ResourcePolicyLiFo(); + + /** \brief Initialize the inner components of the policy. + * + * Because it's a pure virtual method, must be re-implemented + * in concrete derived classes. + */ + virtual void configure() throw(UserInterruptException); + + /** \brief Mixes the queues. + * + * Because it's a pure virtual method, must be re-implemented + * in concrete derived classes. + */ + virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException); + + /** \brief Gets a string description of the policy. + * + * Because it's a pure virtual method, must be re-implemented + * in concrete derived classes. + * \return String description of the policy. + */ + virtual Glib::ustring get_description() const; + + /** \brief Returns the policy name + */ + virtual Glib::ustring get_name() const; + + /** \brief No-op method. + * + * \see ResourcePolicy::activate() + */ + virtual void activate(); + + /** \brief No-op method. + * + * \see ResourcePolicy::deactivate() + */ + virtual void deactivate(); + }; + +}//~ namespace sgpem + + +#endif diff --git a/src/backend/resource_policy_priority.cc b/src/backend/resource_policy_priority.cc index 56610d9..35bf804 100644 --- a/src/backend/resource_policy_priority.cc +++ b/src/backend/resource_policy_priority.cc @@ -18,9 +18,9 @@ // along with SGPEMv2; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#include -#include +#include "resource_policy_priority.hh" +#include using namespace sgpem; @@ -29,12 +29,6 @@ ResourcePolicyPriority::~ResourcePolicyPriority() } -PolicyParameters& -ResourcePolicyPriority::get_parameters() -{ - return _parameters; -} - void ResourcePolicyPriority::configure() throw(UserInterruptException) diff --git a/src/backend/sgpemv2/resource_policy_lifo.hh b/src/backend/resource_policy_priority.hh similarity index 72% rename from src/backend/sgpemv2/resource_policy_lifo.hh rename to src/backend/resource_policy_priority.hh index 9148460..1d29c56 100644 --- a/src/backend/sgpemv2/resource_policy_lifo.hh +++ b/src/backend/resource_policy_priority.hh @@ -1,4 +1,4 @@ -// src/backend/sgpemv2/resource_policy_lifo.hh - Copyright 2005, 2006, University +// src/backend/resource_policy_priority.hh - Copyright 2005, 2006, University // of Padova, dept. of Pure and Applied // Mathematics // @@ -18,27 +18,29 @@ // along with SGPEMv2; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#ifndef RESOURCE_POLICY_LIFO_HH -#define RESOURCE_POLICY_LIFO_HH 1 +#ifndef RESOURCE_POLICY_PRIORITY_HH +#define RESOURCE_POLICY_PRIORITY_HH 1 + +#include "gettext.h" #include +#include +#include + +#include namespace sgpem { - class ResourcePolicyLiFo; + class ResourcePolicyPriority; /** \brief It's a Strategy wich stay for a resource allocating algorithm. It implements the related resource allocation policy. */ - class SG_DLLEXPORT ResourcePolicyLiFo : public ResourcePolicy + class ResourcePolicyPriority : public ResourcePolicy { public: - - /// \brief Standard virtual destructor. - /// - /// Standard virtual destructor. - virtual ~ResourcePolicyLiFo(); + virtual ~ResourcePolicyPriority(); /** Initialize the inner components of the policy. @@ -49,10 +51,7 @@ namespace sgpem virtual void configure() throw(UserInterruptException); /** - Mixes the queues. - - Because it's a pure virtual method, must be re-implemented - in concrete derived classes. + Mixes the queues. */ virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException); @@ -70,16 +69,6 @@ namespace sgpem virtual void activate(); virtual void deactivate(); - - /** - Gets the parameters related with this policy. - - \return The policy parameters. - */ - PolicyParameters& get_parameters(); - - protected: - PolicyParameters _parameters; }; }//~ namespace sgpem diff --git a/src/backend/resource_policy_priority_inheritance.cc b/src/backend/resource_policy_priority_inheritance.cc index 881ebb7..128e661 100644 --- a/src/backend/resource_policy_priority_inheritance.cc +++ b/src/backend/resource_policy_priority_inheritance.cc @@ -18,7 +18,8 @@ // along with SGPEMv2; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -#include +#include "resource_policy_priority_inheritance.hh" + #include using namespace std; @@ -27,13 +28,6 @@ using namespace sgpem; ResourcePolicyPriorityInheritance::~ResourcePolicyPriorityInheritance() {} - -PolicyParameters& -ResourcePolicyPriorityInheritance::get_parameters() -{ - return _parameters; -} - void ResourcePolicyPriorityInheritance::configure() throw(UserInterruptException) diff --git a/src/backend/sgpemv2/resource_policy_priority_inheritance.hh b/src/backend/resource_policy_priority_inheritance.hh similarity index 85% rename from src/backend/sgpemv2/resource_policy_priority_inheritance.hh rename to src/backend/resource_policy_priority_inheritance.hh index 018bcdc..d8dd69a 100644 --- a/src/backend/sgpemv2/resource_policy_priority_inheritance.hh +++ b/src/backend/resource_policy_priority_inheritance.hh @@ -1,4 +1,4 @@ -// src/backend/sgpemv2/resource_policy_priority_inheritance.hh - Copyright 2005, 2006, University +// src/backend/resource_policy_priority_inheritance.hh - Copyright 2005, 2006, University // of Padova, dept. of Pure and Applied // Mathematics // @@ -34,7 +34,7 @@ namespace sgpem * \brief It's a Strategy wich stay for a resource allocating algorithm. * It implements the related resource allocation policy. */ - class SG_DLLEXPORT ResourcePolicyPriorityInheritance : public ResourcePolicy + class ResourcePolicyPriorityInheritance : public ResourcePolicy { public: @@ -75,16 +75,6 @@ namespace sgpem virtual void activate(); virtual void deactivate(); - - /** - \brief Gets the parameters related with this policy. - - \return The policy parameters. - */ - PolicyParameters& get_parameters(); - - protected: - PolicyParameters _parameters; }; }//~ namespace sgpem diff --git a/src/backend/sgpemv2/null_policy_exception.hh b/src/backend/sgpemv2/null_policy_exception.hh index 848aee2..93259cc 100644 --- a/src/backend/sgpemv2/null_policy_exception.hh +++ b/src/backend/sgpemv2/null_policy_exception.hh @@ -1,4 +1,4 @@ -// src/backend/null_policy_exception.hh - Copyright 2005, 2006, University +// src/backend/sgpemv2/null_policy_exception.hh - Copyright 2005, 2006, University // of Padova, dept. of Pure and Applied // Mathematics // @@ -33,10 +33,13 @@ namespace sgpem { class NullPolicyException; + /** \brief Exception thrown when no policy has been selected and + * an operation that involves scheduling is requested + */ class SG_DLLEXPORT NullPolicyException : public std::runtime_error { public: - NullPolicyException(const char* msg = ""); + explicit NullPolicyException(const char* msg = ""); }; } //~ namespace sgpem diff --git a/src/backend/sgpemv2/resource_policy_priority.hh b/src/backend/sgpemv2/resource_policy_priority.hh deleted file mode 100644 index be1f3bf..0000000 --- a/src/backend/sgpemv2/resource_policy_priority.hh +++ /dev/null @@ -1,99 +0,0 @@ -// src/backend/sgpemv2/resource_policy_priority.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 - -#ifndef RESOURCE_POLICY_PRIORITY_HH -#define RESOURCE_POLICY_PRIORITY_HH 1 - -#include - -namespace sgpem -{ - - /// \brief A resource allocation policy which provides a better service - /// to higer priority threads. - /// - /// A resource allocation policy which provides a better service - /// to higer priority threads. This policy sorts the request queues - /// following the priority of the owners of the requests. - class ResourcePolicyPriority; - - class SG_DLLEXPORT ResourcePolicyPriority : public ResourcePolicy - { - public: - - /// \brief Standard virtual destructor. - /// - /// Standard virtual destructor. - virtual ~ResourcePolicyPriority(); - - /// \brief Initializes the inner components of the policy. - /// - /// Does nothing. - virtual void configure() throw(UserInterruptException); - - /// \brief Sorts the subrequest queue letting higher priority threads to be the first ones - /// to get the resources. - /// - /// Sorts the subrequest queue letting higher priority threads to be the first ones - /// to get the resources. - /// - /// \param environment the environment on which the policy applies. - /// \param queue the queue where a subrequest has just been added. - /// \param sr the subrequest which has just been added. - virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException); - - /// \brief Returns a description of the policy. - /// - /// Returns a description of the policy. - /// \return a description of the policy. - virtual Glib::ustring get_description() const; - - /// \brief Returns the name of the policy. - /// - /// Returns the name of the policy. - /// \return the name of the policy. - virtual Glib::ustring get_name() const; - - - /// \brief Activates the policy. - /// - /// Does nothing. - virtual void activate(); - - /// \brief Deactivates the policy. - /// - /// Does nothing. - virtual void deactivate(); - - /// \brief Returns the parameters used to customize the policy. - /// - /// Returns the parameters used to customize the policy. - /// The user may modify them directly. - /// \return the parameters used to customize the policy. - PolicyParameters& get_parameters(); - - protected: - PolicyParameters _parameters; - }; - -}//~ namespace sgpem - - -#endif