- Separate template definition from template declaration
- Explicitly instantiate Singleton templates to be exported from libbackend.so - Install only header files that are backend interfaces to be exposed to the user - Don't use full path for including templates in header files - Instantiate a couple of smart_ptr templates to have their symbols exported outside the DSO. This happens in history.cc. FIXME: the interface for History will definitely need to be reworked, and the two smart_ptr explicit instantiations removed. - Change SWIG exported interface to make use of Schedulable instead of (Dynamic|Static)Schedulable - Fix provided policies to make use of the new interface - TODO: limit the use of smart_ptrs. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@653 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
56db7cd6a2
commit
66d46db357
29
Makefile.am
29
Makefile.am
|
@ -45,9 +45,9 @@ aclocaldir = @datadir@/aclocal
|
||||||
|
|
||||||
#define empty global variables
|
#define empty global variables
|
||||||
bin_PROGRAMS =
|
bin_PROGRAMS =
|
||||||
|
pkglib_LTLIBRARIES =
|
||||||
plugin_LTLIBRARIES =
|
plugin_LTLIBRARIES =
|
||||||
noinst_HEADERS =
|
noinst_HEADERS =
|
||||||
pkglib_LTLIBRARIES =
|
|
||||||
pkginclude_HEADERS =
|
pkginclude_HEADERS =
|
||||||
EXTRA_DIST =
|
EXTRA_DIST =
|
||||||
MAINTAINERCLEANFILES =
|
MAINTAINERCLEANFILES =
|
||||||
|
@ -175,14 +175,10 @@ src_backend_libbackend_la_SOURCES = \
|
||||||
src/backend/thread.cc \
|
src/backend/thread.cc \
|
||||||
src/backend/user_interrupt_exception.cc
|
src/backend/user_interrupt_exception.cc
|
||||||
|
|
||||||
|
# Put here header files that will be installed for the user
|
||||||
|
# For headers used internally by the backend, see below.
|
||||||
pkginclude_HEADERS += \
|
pkginclude_HEADERS += \
|
||||||
config.h \
|
config.h \
|
||||||
src/backend/dynamic_process.hh \
|
|
||||||
src/backend/dynamic_request.hh \
|
|
||||||
src/backend/dynamic_resource.hh \
|
|
||||||
src/backend/dynamic_schedulable.hh \
|
|
||||||
src/backend/dynamic_sub_request.hh \
|
|
||||||
src/backend/dynamic_thread.hh \
|
|
||||||
src/backend/global_preferences.hh \
|
src/backend/global_preferences.hh \
|
||||||
src/backend/history.hh \
|
src/backend/history.hh \
|
||||||
src/backend/observed_subject.hh \
|
src/backend/observed_subject.hh \
|
||||||
|
@ -198,16 +194,27 @@ pkginclude_HEADERS += \
|
||||||
src/backend/schedulable_queue.hh \
|
src/backend/schedulable_queue.hh \
|
||||||
src/backend/scheduler.hh \
|
src/backend/scheduler.hh \
|
||||||
src/backend/slice.hh \
|
src/backend/slice.hh \
|
||||||
|
src/backend/sub_request.hh \
|
||||||
|
src/backend/thread.hh \
|
||||||
|
src/backend/user_interrupt_exception.hh
|
||||||
|
|
||||||
|
# Put here headers used internally by the backend
|
||||||
|
# They won't be installed for the end-user.
|
||||||
|
noinst_HEADERS += \
|
||||||
|
src/backend/dynamic_process.hh \
|
||||||
|
src/backend/dynamic_request.hh \
|
||||||
|
src/backend/dynamic_resource.hh \
|
||||||
|
src/backend/dynamic_schedulable.hh \
|
||||||
|
src/backend/dynamic_sub_request.hh \
|
||||||
|
src/backend/dynamic_thread.hh \
|
||||||
src/backend/static_process.hh \
|
src/backend/static_process.hh \
|
||||||
src/backend/static_request.hh \
|
src/backend/static_request.hh \
|
||||||
src/backend/static_resource.hh \
|
src/backend/static_resource.hh \
|
||||||
src/backend/static_schedulable.hh \
|
src/backend/static_schedulable.hh \
|
||||||
src/backend/static_sub_request.hh \
|
src/backend/static_sub_request.hh \
|
||||||
src/backend/static_thread.hh \
|
src/backend/static_thread.hh \
|
||||||
src/backend/string_utils.hh \
|
src/backend/string_utils.hh
|
||||||
src/backend/sub_request.hh \
|
|
||||||
src/backend/thread.hh \
|
|
||||||
src/backend/user_interrupt_exception.hh
|
|
||||||
|
|
||||||
# ############################################################
|
# ############################################################
|
||||||
#
|
#
|
||||||
|
|
|
@ -41,6 +41,6 @@ class fcfs(Policy) :
|
||||||
|
|
||||||
def sort_queue(self, queue):
|
def sort_queue(self, queue):
|
||||||
cmpf = lambda a, b: \
|
cmpf = lambda a, b: \
|
||||||
a.get_schedulable().get_arrival_time() < \
|
a.get_arrival_time() < \
|
||||||
b.get_schedulable().get_arrival_time()
|
b.get_arrival_time()
|
||||||
self.sort(queue,cmpf)
|
self.sort(queue,cmpf)
|
||||||
|
|
|
@ -41,6 +41,6 @@ class sjf(Policy) :
|
||||||
|
|
||||||
def sort_queue(self, queue):
|
def sort_queue(self, queue):
|
||||||
cmpf = lambda a, b: \
|
cmpf = lambda a, b: \
|
||||||
a.get_cpu_time_left() < \
|
a.get_remaining_time() < \
|
||||||
b.get_cpu_time_left()
|
b.get_remaining_time()
|
||||||
self.sort(queue,cmpf)
|
self.sort(queue,cmpf)
|
||||||
|
|
|
@ -130,43 +130,11 @@ namespace sgpem {
|
||||||
}; //~ class PolicyParameters
|
}; //~ class PolicyParameters
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
class StaticSchedulable
|
class Schedulable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~StaticSchedulable() = 0;
|
virtual ~Schedulable() = 0;
|
||||||
|
|
||||||
virtual unsigned int get_arrival_time() const;
|
|
||||||
int get_priority() const;
|
|
||||||
unsigned int get_total_cpu_time() const;
|
|
||||||
|
|
||||||
%ignore StaticSchedulable::get_name() const;
|
|
||||||
%extend {
|
|
||||||
const char* get_name() const
|
|
||||||
{ return self->get_name().c_str(); }
|
|
||||||
}
|
|
||||||
}; //~ class StaticSchedulable
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------
|
|
||||||
class SchedulableQueue
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
unsigned int size() const;
|
|
||||||
const sgpem::DynamicSchedulable* get_item_at(const unsigned int&) const;
|
|
||||||
void swap(unsigned int positionA, unsigned int positionB) throw();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Avoid instantiation and copy
|
|
||||||
SchedulableQueue();
|
|
||||||
SchedulableQueue(const SchedulableQueue&);
|
|
||||||
SchedulableQueue& operator=(const SchedulableQueue&);
|
|
||||||
~SchedulableQueue();
|
|
||||||
}; //~ class Schedulable
|
|
||||||
|
|
||||||
// ---------------------------------------------
|
|
||||||
class DynamicSchedulable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum state
|
enum state
|
||||||
{
|
{
|
||||||
state_running = 1<<0,
|
state_running = 1<<0,
|
||||||
|
@ -176,13 +144,36 @@ namespace sgpem {
|
||||||
state_terminated = 1<<4
|
state_terminated = 1<<4
|
||||||
};
|
};
|
||||||
|
|
||||||
DynamicSchedulable(const DynamicSchedulable& obj);
|
virtual unsigned int get_arrival_time() const = 0;
|
||||||
|
virtual unsigned int get_remaining_time() const = 0;
|
||||||
|
virtual int get_base_priority() const = 0;
|
||||||
|
virtual int get_current_priority() const = 0;
|
||||||
|
virtual unsigned int get_total_cpu_time() const = 0;
|
||||||
|
virtual state get_state() const = 0;
|
||||||
|
|
||||||
int get_cpu_time_left() const;
|
%ignore Schedulable::get_name() const;
|
||||||
int get_last_scheduled() const;
|
%extend {
|
||||||
state get_state() const;
|
const char* get_name() const
|
||||||
const sgpem::StaticSchedulable* get_schedulable() const;
|
{ return self->get_name().c_str(); }
|
||||||
};
|
}
|
||||||
|
}; //~ class Schedulable
|
||||||
|
|
||||||
|
|
||||||
|
// --------------------------------------------
|
||||||
|
class SchedulableQueue
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
unsigned int size() const;
|
||||||
|
const sgpem::Schedulable* get_item_at(const unsigned int&) const;
|
||||||
|
void swap(unsigned int positionA, unsigned int positionB) throw();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Avoid instantiation and copy
|
||||||
|
SchedulableQueue();
|
||||||
|
SchedulableQueue(const SchedulableQueue&);
|
||||||
|
SchedulableQueue& operator=(const SchedulableQueue&);
|
||||||
|
~SchedulableQueue();
|
||||||
|
}; //~ class Schedulable
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
class Scheduler {
|
class Scheduler {
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "process.hh"
|
#include "process.hh"
|
||||||
#include "../templates/smartp.hh"
|
|
||||||
#include "dynamic_schedulable.hh"
|
#include "dynamic_schedulable.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
#include "dynamic_request.hh"
|
#include "dynamic_request.hh"
|
||||||
#include "static_request.hh"
|
#include "static_request.hh"
|
||||||
#include "dynamic_sub_request.hh"
|
#include "dynamic_sub_request.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
|
@ -22,11 +22,14 @@
|
||||||
#define DYNAMIC_REQUEST_HH 1
|
#define DYNAMIC_REQUEST_HH 1
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "../templates/smartp.hh"
|
|
||||||
#include <vector>
|
|
||||||
#include "request.hh"
|
#include "request.hh"
|
||||||
#include "static_request.hh"
|
#include "static_request.hh"
|
||||||
|
|
||||||
|
#include "smartp.hh"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class DynamicRequest;
|
class DynamicRequest;
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "dynamic_resource.hh"
|
#include "dynamic_resource.hh"
|
||||||
#include "static_resource.hh"
|
#include "static_resource.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
DynamicResource::DynamicResource(StaticResource *core) :
|
DynamicResource::DynamicResource(StaticResource *core) :
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glibmm/ustring.h"
|
#include "glibmm/ustring.h"
|
||||||
#include "../templates/smartp.hh"
|
|
||||||
|
#include "smartp.hh"
|
||||||
|
|
||||||
#include "resource.hh"
|
#include "resource.hh"
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include "dynamic_schedulable.hh"
|
#include "dynamic_schedulable.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "schedulable.hh"
|
#include "schedulable.hh"
|
||||||
#include "static_schedulable.hh"
|
#include "static_schedulable.hh"
|
||||||
#include "../templates/smartp.hh"
|
|
||||||
|
#include "smartp.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
|
|
||||||
#include "dynamic_sub_request.hh"
|
#include "dynamic_sub_request.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,
|
DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "dynamic_resource.hh"
|
#include "dynamic_resource.hh"
|
||||||
#include "static_sub_request.hh"
|
#include "static_sub_request.hh"
|
||||||
|
|
||||||
|
#include "smartp.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class DynamicSubRequest;
|
class DynamicSubRequest;
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include "dynamic_request.hh"
|
#include "dynamic_request.hh"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,10 @@
|
||||||
|
|
||||||
#include "thread.hh"
|
#include "thread.hh"
|
||||||
#include "dynamic_process.hh"
|
#include "dynamic_process.hh"
|
||||||
#include "../templates/smartp.hh"
|
|
||||||
#include "dynamic_schedulable.hh"
|
#include "dynamic_schedulable.hh"
|
||||||
|
|
||||||
|
#include "smartp.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class DynamicThread;
|
class DynamicThread;
|
||||||
|
|
|
@ -21,9 +21,12 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "global_preferences.hh"
|
#include "global_preferences.hh"
|
||||||
|
|
||||||
|
// Do not include in header file:
|
||||||
|
#include "singleton.tcc"
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
GlobalPreferences* GlobalPreferences::_instance = NULL;
|
// Explicit template instantiation to allow to export symbols from the DSO.
|
||||||
|
template class SG_DLLEXPORT Singleton<GlobalPreferences>;
|
||||||
|
|
||||||
GlobalPreferences::GlobalPreferences()
|
GlobalPreferences::GlobalPreferences()
|
||||||
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR)
|
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR)
|
||||||
|
@ -71,10 +74,3 @@ GlobalPreferences::add_policies_dir(const Glib::ustring& poldir)
|
||||||
_pol_dirs.insert(_pol_dirs.begin(), poldir);
|
_pol_dirs.insert(_pol_dirs.begin(), poldir);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalPreferences&
|
|
||||||
GlobalPreferences::get_instance()
|
|
||||||
{
|
|
||||||
if(_instance == NULL)
|
|
||||||
_instance = new GlobalPreferences();
|
|
||||||
return *_instance;
|
|
||||||
}
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// Do not include complete template definition here:
|
||||||
#include "singleton.hh"
|
#include "singleton.hh"
|
||||||
|
|
||||||
namespace sgpem {
|
namespace sgpem {
|
||||||
|
@ -35,7 +36,7 @@ namespace sgpem {
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
namespace sgpem {
|
namespace sgpem {
|
||||||
class SG_DLLEXPORT GlobalPreferences /*: public Singleton<GlobalPreferences>*/
|
class SG_DLLEXPORT GlobalPreferences : public Singleton<GlobalPreferences>
|
||||||
{
|
{
|
||||||
friend class Singleton<GlobalPreferences>;
|
friend class Singleton<GlobalPreferences>;
|
||||||
|
|
||||||
|
@ -51,8 +52,6 @@ namespace sgpem {
|
||||||
void add_modules_dir(const Glib::ustring& moddir);
|
void add_modules_dir(const Glib::ustring& moddir);
|
||||||
void add_policies_dir(const Glib::ustring& poldir);
|
void add_policies_dir(const Glib::ustring& poldir);
|
||||||
|
|
||||||
static GlobalPreferences& get_instance();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlobalPreferences();
|
GlobalPreferences();
|
||||||
GlobalPreferences(const GlobalPreferences&);
|
GlobalPreferences(const GlobalPreferences&);
|
||||||
|
@ -60,8 +59,6 @@ namespace sgpem {
|
||||||
|
|
||||||
std::vector<Glib::ustring> _mod_dirs;
|
std::vector<Glib::ustring> _mod_dirs;
|
||||||
std::vector<Glib::ustring> _pol_dirs;
|
std::vector<Glib::ustring> _pol_dirs;
|
||||||
|
|
||||||
static GlobalPreferences* _instance;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,24 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "history.hh"
|
#include "history.hh"
|
||||||
|
|
||||||
|
// Do not include in header file:
|
||||||
|
#include "singleton.tcc"
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace memory;
|
using namespace memory;
|
||||||
|
|
||||||
History* History::_instance = NULL;
|
// Explicit template instantiation to allow to export symbols from the DSO.
|
||||||
|
template class SG_DLLEXPORT Singleton<History>;
|
||||||
|
|
||||||
|
// FIXME: These two should disappear!!!
|
||||||
|
template class SG_DLLEXPORT smart_ptr<SchedulableQueue>;
|
||||||
|
template class SG_DLLEXPORT smart_ptr<DynamicSchedulable>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The constructor sets _total_time_elapsed to -1: this permits to insert the INITIAL STATUS
|
The constructor sets _total_time_elapsed to -1: this permits to insert the INITIAL STATUS
|
||||||
|
@ -135,12 +147,3 @@ History::truncate_at(int instant)
|
||||||
notify();
|
notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
History&
|
|
||||||
History::get_instance()
|
|
||||||
{
|
|
||||||
if(_instance == NULL)
|
|
||||||
_instance = new History();
|
|
||||||
return *_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,9 @@
|
||||||
#include "observed_subject.hh"
|
#include "observed_subject.hh"
|
||||||
#include "schedulable_queue.hh"
|
#include "schedulable_queue.hh"
|
||||||
#include "dynamic_schedulable.hh"
|
#include "dynamic_schedulable.hh"
|
||||||
#include "../templates/smartp.hh"
|
#include "smartp.hh"
|
||||||
|
|
||||||
|
// Do not include complete template definition here:
|
||||||
#include "singleton.hh"
|
#include "singleton.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
|
@ -49,7 +50,7 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
class History;
|
class History;
|
||||||
|
|
||||||
class SG_DLLEXPORT History : /*public Singleton<History>,*/ public ObservedSubject
|
class SG_DLLEXPORT History : public Singleton<History>, public ObservedSubject
|
||||||
{
|
{
|
||||||
friend class Singleton<History>;
|
friend class Singleton<History>;
|
||||||
|
|
||||||
|
@ -86,9 +87,6 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
virtual void truncate_at(int instant);
|
virtual void truncate_at(int instant);
|
||||||
|
|
||||||
static History& get_instance();
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
History(); //private constructor.
|
History(); //private constructor.
|
||||||
History(const History&);
|
History(const History&);
|
||||||
|
@ -97,7 +95,6 @@ namespace sgpem
|
||||||
private:
|
private:
|
||||||
int _total_time_elapsed;
|
int _total_time_elapsed;
|
||||||
std::vector<sgpem::Slice> _slices;
|
std::vector<sgpem::Slice> _slices;
|
||||||
static History* _instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
|
@ -18,10 +18,15 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "policies_gatekeeper.hh"
|
#include "policies_gatekeeper.hh"
|
||||||
#include "policy_manager.hh"
|
#include "policy_manager.hh"
|
||||||
#include "policy.hh"
|
#include "policy.hh"
|
||||||
|
|
||||||
|
// Include full template definition only in implementation files:
|
||||||
|
#include "singleton.tcc"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
@ -31,11 +36,12 @@ using std::find;
|
||||||
using std::runtime_error;
|
using std::runtime_error;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
|
// Explicit template instantiation to allow to export symbols from the DSO.
|
||||||
|
template class SG_DLLEXPORT Singleton<PoliciesGatekeeper>;
|
||||||
|
|
||||||
typedef vector<PolicyManager*>::iterator ManagerIterator;
|
typedef vector<PolicyManager*>::iterator ManagerIterator;
|
||||||
typedef map<History*, Policy*>::iterator ActiveIterator;
|
typedef map<History*, Policy*>::iterator ActiveIterator;
|
||||||
|
|
||||||
PoliciesGatekeeper* PoliciesGatekeeper::_instance = NULL;
|
|
||||||
|
|
||||||
vector<PolicyManager*>
|
vector<PolicyManager*>
|
||||||
PoliciesGatekeeper::get_registered() const
|
PoliciesGatekeeper::get_registered() const
|
||||||
{
|
{
|
||||||
|
@ -131,11 +137,3 @@ PoliciesGatekeeper::deactivate_policies(PolicyManager* manager)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PoliciesGatekeeper&
|
|
||||||
PoliciesGatekeeper::get_instance()
|
|
||||||
{
|
|
||||||
if(_instance == NULL)
|
|
||||||
_instance = new PoliciesGatekeeper();
|
|
||||||
return *_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace sgpem
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SG_DLLEXPORT PoliciesGatekeeper /*: public Singleton<PoliciesGatekeeper>*/
|
class SG_DLLEXPORT PoliciesGatekeeper : public Singleton<PoliciesGatekeeper>
|
||||||
{
|
{
|
||||||
friend class Singleton<PoliciesGatekeeper>;
|
friend class Singleton<PoliciesGatekeeper>;
|
||||||
|
|
||||||
|
@ -60,8 +60,6 @@ namespace sgpem
|
||||||
|
|
||||||
void activate_policy(History* history, Policy* policy);
|
void activate_policy(History* history, Policy* policy);
|
||||||
|
|
||||||
static PoliciesGatekeeper& get_instance();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PoliciesGatekeeper(); //private constructor.
|
PoliciesGatekeeper(); //private constructor.
|
||||||
PoliciesGatekeeper(const PoliciesGatekeeper&);
|
PoliciesGatekeeper(const PoliciesGatekeeper&);
|
||||||
|
@ -72,7 +70,6 @@ namespace sgpem
|
||||||
|
|
||||||
std::vector<PolicyManager*> _registered;
|
std::vector<PolicyManager*> _registered;
|
||||||
std::map<History*, Policy*> _active_policies;
|
std::map<History*, Policy*> _active_policies;
|
||||||
static PoliciesGatekeeper* _instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace sgpem
|
||||||
state_terminated = 1<<4
|
state_terminated = 1<<4
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Schedulable();
|
virtual ~Schedulable() = 0;
|
||||||
|
|
||||||
virtual Glib::ustring get_name() const = 0;
|
virtual Glib::ustring get_name() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include "schedulable_queue.hh"
|
#include "schedulable_queue.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace memory;
|
using namespace memory;
|
||||||
|
|
|
@ -23,10 +23,11 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include "dynamic_schedulable.hh"
|
#include "dynamic_schedulable.hh"
|
||||||
#include "../templates/smartp.hh"
|
|
||||||
|
#include "smartp.hh"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
|
|
|
@ -24,12 +24,16 @@
|
||||||
#include "policies_gatekeeper.hh"
|
#include "policies_gatekeeper.hh"
|
||||||
#include "user_interrupt_exception.hh"
|
#include "user_interrupt_exception.hh"
|
||||||
|
|
||||||
|
// Do not include full template definition in the header file
|
||||||
|
#include "singleton.tcc"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace memory;
|
using namespace memory;
|
||||||
|
|
||||||
Scheduler* Scheduler::_instance = NULL;
|
// Explicit template instantiation to allow to export symbols from the DSO.
|
||||||
|
template class SG_DLLEXPORT Singleton<Scheduler>;
|
||||||
|
|
||||||
//private constructor. The parameter is discarded
|
//private constructor. The parameter is discarded
|
||||||
Scheduler::Scheduler()
|
Scheduler::Scheduler()
|
||||||
|
@ -207,10 +211,3 @@ Scheduler::step_forward() throw(UserInterruptException)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Scheduler&
|
|
||||||
Scheduler::get_instance()
|
|
||||||
{
|
|
||||||
if(_instance == NULL)
|
|
||||||
_instance = new Scheduler();
|
|
||||||
return *_instance;
|
|
||||||
}
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace sgpem
|
||||||
#include "schedulable_queue.hh"
|
#include "schedulable_queue.hh"
|
||||||
#include "user_interrupt_exception.hh"
|
#include "user_interrupt_exception.hh"
|
||||||
|
|
||||||
|
// Do not include full template definition here
|
||||||
#include "singleton.hh"
|
#include "singleton.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
|
@ -54,7 +55,7 @@ namespace sgpem
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SG_DLLEXPORT Scheduler /*: public Singleton<Scheduler>*/
|
class SG_DLLEXPORT Scheduler : public Singleton<Scheduler>
|
||||||
{
|
{
|
||||||
friend class Singleton<Scheduler>;
|
friend class Singleton<Scheduler>;
|
||||||
public:
|
public:
|
||||||
|
@ -88,14 +89,10 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
Policy& get_policy();
|
Policy& get_policy();
|
||||||
|
|
||||||
static Scheduler& get_instance();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Scheduler(); //private constructor.
|
Scheduler(); //private constructor.
|
||||||
SchedulableQueue _ready_queue;
|
SchedulableQueue _ready_queue;
|
||||||
PolicyManager& _policy_manager;
|
PolicyManager& _policy_manager;
|
||||||
static Scheduler* _instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "static_thread.hh"
|
#include "static_thread.hh"
|
||||||
#include "static_request.hh"
|
#include "static_request.hh"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "parse_opts.hh"
|
#include "parse_opts.hh"
|
||||||
#include "start_gui.hh"
|
#include "start_gui.hh"
|
||||||
|
|
||||||
#include "templates/smartp.hh"
|
|
||||||
#include "backend/history.hh"
|
#include "backend/history.hh"
|
||||||
#include "backend/static_schedulable.hh"
|
#include "backend/static_schedulable.hh"
|
||||||
#include "backend/schedulable_queue.hh"
|
#include "backend/schedulable_queue.hh"
|
||||||
|
@ -38,6 +37,8 @@
|
||||||
#include "standard_io.hh"
|
#include "standard_io.hh"
|
||||||
#include "text_simulation.hh"
|
#include "text_simulation.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
#include <glibmm/module.h>
|
#include <glibmm/module.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include "simulation.hh"
|
#include "simulation.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace memory;
|
using namespace memory;
|
||||||
|
|
|
@ -21,10 +21,9 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
|
|
||||||
#include "graphical_terminal_io.hh"
|
#include "graphical_terminal_io.hh"
|
||||||
#include "start_gui.hh"
|
#include "start_gui.hh"
|
||||||
#include "templates/smartp.hh"
|
#include "smartp.tcc"
|
||||||
|
|
||||||
#include <gtkmm/main.h>
|
#include <gtkmm/main.h>
|
||||||
|
|
||||||
|
|
|
@ -47,13 +47,10 @@ namespace sgpem
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Instantiated_class* _instance;
|
static Instantiated_class* _instance;
|
||||||
static Glib::StaticMutex _mutex;
|
static Glib::StaticMutex SG_DLLLOCAL _mutex;
|
||||||
}; //~ class Singleton
|
}; //~ class Singleton
|
||||||
|
|
||||||
} //~ namespace sgpem
|
} //~ namespace sgpem
|
||||||
|
|
||||||
|
|
||||||
#include "singleton.tcc"
|
|
||||||
|
|
||||||
#endif //~ SINGLETON_HH
|
#endif //~ SINGLETON_HH
|
||||||
|
|
||||||
|
|
|
@ -85,41 +85,41 @@ namespace memory {
|
||||||
|
|
||||||
smart_ptr& operator=(const smart_ptr& sptr) throw();
|
smart_ptr& operator=(const smart_ptr& sptr) throw();
|
||||||
|
|
||||||
inline bool operator==(const smart_ptr& sptr) const throw();
|
bool operator==(const smart_ptr& sptr) const throw();
|
||||||
inline bool operator!=(const smart_ptr& sptr) const throw();
|
bool operator!=(const smart_ptr& sptr) const throw();
|
||||||
|
|
||||||
/** \brief Access to stored object's members
|
/** \brief Access to stored object's members
|
||||||
*
|
*
|
||||||
* Use this operator to access object
|
* Use this operator to access object
|
||||||
* methods and data. */
|
* methods and data. */
|
||||||
inline T* operator->() throw();
|
T* operator->() throw();
|
||||||
|
|
||||||
/** \brief Access to stored object's members
|
/** \brief Access to stored object's members
|
||||||
*
|
*
|
||||||
* Const version of the above operator. */
|
* Const version of the above operator. */
|
||||||
inline const T* operator->() const throw();
|
const T* operator->() const throw();
|
||||||
|
|
||||||
/** \brief Access to stored object
|
/** \brief Access to stored object
|
||||||
*
|
*
|
||||||
* \warning Use with care */
|
* \warning Use with care */
|
||||||
inline T& operator*() throw();
|
T& operator*() throw();
|
||||||
|
|
||||||
/** \brief Access to stored object
|
/** \brief Access to stored object
|
||||||
*
|
*
|
||||||
* \warning Use with care */
|
* \warning Use with care */
|
||||||
inline const T& operator*() const throw();
|
const T& operator*() const throw();
|
||||||
|
|
||||||
/** \brief Convenience operator for use in predicates
|
/** \brief Convenience operator for use in predicates
|
||||||
*
|
*
|
||||||
* \return true if the stored pointer is valid,
|
* \return true if the stored pointer is valid,
|
||||||
* false otherwise. */
|
* false otherwise. */
|
||||||
inline operator bool() const throw();
|
operator bool() const throw();
|
||||||
|
|
||||||
/** \brief Returns the number of alive references to
|
/** \brief Returns the number of alive references to
|
||||||
* the stored object
|
* the stored object
|
||||||
*
|
*
|
||||||
* \return The number of references */
|
* \return The number of references */
|
||||||
inline unsigned int alive_refs() const throw();
|
unsigned int alive_refs() const throw();
|
||||||
|
|
||||||
/** \brief Dynamic cast the stored pointer
|
/** \brief Dynamic cast the stored pointer
|
||||||
* to another type, returning a smart_ptr
|
* to another type, returning a smart_ptr
|
||||||
|
@ -133,7 +133,7 @@ namespace memory {
|
||||||
* the cast isn't successful or doable
|
* the cast isn't successful or doable
|
||||||
*/
|
*/
|
||||||
template<typename U>
|
template<typename U>
|
||||||
inline smart_ptr<U,isArray> cast_to() throw(std::bad_cast);
|
smart_ptr<U,isArray> cast_to() throw(std::bad_cast);
|
||||||
|
|
||||||
/** \brief Dynamic cast the stored pointer
|
/** \brief Dynamic cast the stored pointer
|
||||||
* to another type, returning a smart_ptr
|
* to another type, returning a smart_ptr
|
||||||
|
@ -147,7 +147,7 @@ namespace memory {
|
||||||
* the cast isn't successful or doable
|
* the cast isn't successful or doable
|
||||||
*/
|
*/
|
||||||
template<typename U>
|
template<typename U>
|
||||||
inline const smart_ptr<U,isArray> cast_to() const throw(std::bad_cast);
|
const smart_ptr<U,isArray> cast_to() const throw(std::bad_cast);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename U>
|
template<typename U>
|
||||||
|
@ -160,7 +160,5 @@ namespace memory {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "smartp.tcc"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@
|
||||||
#include "backend/observed_subject.hh"
|
#include "backend/observed_subject.hh"
|
||||||
#include "backend/schedulable_queue.hh"
|
#include "backend/schedulable_queue.hh"
|
||||||
#include "backend/dynamic_schedulable.hh"
|
#include "backend/dynamic_schedulable.hh"
|
||||||
#include "templates/smartp.hh"
|
|
||||||
|
#include "templates/smartp.tcc"
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#include "standard_io.hh"
|
#include "standard_io.hh"
|
||||||
#include "text_simulation.hh"
|
#include "text_simulation.hh"
|
||||||
#include "templates/smartp.hh"
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -42,6 +41,8 @@
|
||||||
#include "backend/schedulable_queue.hh"
|
#include "backend/schedulable_queue.hh"
|
||||||
#include "backend/dynamic_schedulable.hh"
|
#include "backend/dynamic_schedulable.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,12 @@
|
||||||
#include "backend/observed_subject.hh"
|
#include "backend/observed_subject.hh"
|
||||||
#include "backend/schedulable_queue.hh"
|
#include "backend/schedulable_queue.hh"
|
||||||
#include "backend/dynamic_schedulable.hh"
|
#include "backend/dynamic_schedulable.hh"
|
||||||
#include "templates/smartp.hh"
|
|
||||||
|
|
||||||
#include "scheduler.hh"
|
#include "scheduler.hh"
|
||||||
#include "user_interrupt_exception.hh"
|
#include "user_interrupt_exception.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,14 @@
|
||||||
#include "backend/history.hh"
|
#include "backend/history.hh"
|
||||||
|
|
||||||
#include "text_simulation.hh"
|
#include "text_simulation.hh"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace memory;
|
using namespace memory;
|
||||||
using Glib::Thread;
|
using Glib::Thread;
|
||||||
using Glib::ustring;
|
using Glib::ustring;
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
TextSimulation::~TextSimulation()
|
TextSimulation::~TextSimulation()
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "templates/smartp.hh"
|
#include "templates/smartp.hh"
|
||||||
#include "backend/policy_parameters.hh"
|
#include "backend/policy_parameters.hh"
|
||||||
|
|
||||||
|
#include "smartp.hh"
|
||||||
|
|
||||||
#include <glibmm/thread.h>
|
#include <glibmm/thread.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
Loading…
Reference in New Issue