- Add unified Singleton support
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@643 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
8ca3a61730
commit
383889a203
17 changed files with 193 additions and 136 deletions
|
@ -37,11 +37,13 @@ namespace sgpem
|
|||
#include "schedulable_queue.hh"
|
||||
#include "user_interrupt_exception.hh"
|
||||
|
||||
#include "singleton.hh"
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class Scheduler;
|
||||
class Scheduler;
|
||||
|
||||
/** \brief Manages the DynamicSchedulable objects, implementing a given policy.
|
||||
/** \brief Manages the DynamicSchedulable objects, implementing a given policy.
|
||||
|
||||
Class Scheduler manages the schedulable entities which are ready to run,
|
||||
ordering them in a queue; it also checks that the current scheduling policy
|
||||
|
@ -50,61 +52,49 @@ namespace sgpem
|
|||
the DynamicSchedulable objects (for further details about this, check
|
||||
class DynamicSchedulable).
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
class SG_DLLEXPORT Scheduler
|
||||
{
|
||||
public:
|
||||
/** \brief Returns the unique instance of this class, conforming to the Singleton pattern.
|
||||
*
|
||||
* If Scheduler isn't initialized, creates it. Should be called at least once before
|
||||
* starting the Simulation.
|
||||
* \return the unique instance of this class, conforming to the Singleton pattern.
|
||||
*/
|
||||
static Scheduler& get_instance();
|
||||
/**
|
||||
Returns a pointer to the queue containing all the ready
|
||||
schedulable objects (for the policy to sort it).
|
||||
\return a pointer to the queue containing all the ready
|
||||
schedulable objects (for the policy to sort it).
|
||||
*/
|
||||
SchedulableQueue* get_ready_queue();
|
||||
/**
|
||||
Resets the simulation to the initial state.
|
||||
*/
|
||||
void reset_status();
|
||||
/**
|
||||
Generates a new SchedulableQueue representing the status of the processes
|
||||
at the simulation instant next to the current one, and extends the History by
|
||||
one instant with it.
|
||||
*/
|
||||
void step_forward() throw(UserInterruptException);
|
||||
/**
|
||||
Sets the policy that will be used to generate the simulation at the next instant.
|
||||
\param policy the policy that will be used to generate the simulation at the next instant.
|
||||
*/
|
||||
/* DISABLED until we don't have PolicyManager::set_policy()
|
||||
void set_policy(Policy* policy);
|
||||
*/
|
||||
/**
|
||||
Returns the policy that will be used to generate the simulation at the next instant.
|
||||
\return the policy that will be used to generate the simulation at the next instant.
|
||||
*/
|
||||
Policy& get_policy();
|
||||
class SG_DLLEXPORT Scheduler : public Singleton<Scheduler>
|
||||
{
|
||||
friend class Singleton<Scheduler>;
|
||||
public:
|
||||
/**
|
||||
Returns a pointer to the queue containing all the ready
|
||||
schedulable objects (for the policy to sort it).
|
||||
\return a pointer to the queue containing all the ready
|
||||
schedulable objects (for the policy to sort it).
|
||||
*/
|
||||
SchedulableQueue* get_ready_queue();
|
||||
/**
|
||||
Resets the simulation to the initial state.
|
||||
*/
|
||||
void reset_status();
|
||||
/**
|
||||
Generates a new SchedulableQueue representing the status of the processes
|
||||
at the simulation instant next to the current one, and extends the History by
|
||||
one instant with it.
|
||||
*/
|
||||
void step_forward() throw(UserInterruptException);
|
||||
/**
|
||||
Sets the policy that will be used to generate the simulation at the next instant.
|
||||
\param policy the policy that will be used to generate the simulation at the next instant.
|
||||
*/
|
||||
/* DISABLED until we don't have PolicyManager::set_policy()
|
||||
void set_policy(Policy* policy);
|
||||
*/
|
||||
/**
|
||||
Returns the policy that will be used to generate the simulation at the next instant.
|
||||
\return the policy that will be used to generate the simulation at the next instant.
|
||||
*/
|
||||
Policy& get_policy();
|
||||
|
||||
|
||||
private:
|
||||
Scheduler(); //private constructor.
|
||||
static Scheduler* _instance;
|
||||
SchedulableQueue _ready_queue;
|
||||
PolicyManager& _policy_manager;
|
||||
};
|
||||
private:
|
||||
Scheduler(); //private constructor.
|
||||
SchedulableQueue _ready_queue;
|
||||
PolicyManager& _policy_manager;
|
||||
};
|
||||
|
||||
}//~ namespace sgpem
|
||||
|
||||
#endif //SCHEDULER_HH
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue