- Implement a couple of helper methods into Dynamic(Sub)Request to
make life easier to Scheduler - Go on implementing a bit more of Scheduler::step_forward() - Remove "places" from SubRequest git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@778 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
53073295d5
commit
14b5b66b3c
13 changed files with 163 additions and 89 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "dynamic_sub_request.hh"
|
||||
#include "dynamic_request.hh"
|
||||
#include "request.hh"
|
||||
#include "serialize_visitor.hh"
|
||||
|
||||
#include "smartp.tcc"
|
||||
|
@ -32,7 +33,7 @@ using namespace sgpem;
|
|||
DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,
|
||||
DynamicRequest* owner) :
|
||||
_static_subrequest(core), _owner(owner),
|
||||
_queue_position(-1)
|
||||
_queue_position(-1), _ran_for(0), _state(Request::state_future)
|
||||
{
|
||||
assert(core != NULL);
|
||||
assert(owner != NULL);
|
||||
|
@ -45,7 +46,8 @@ DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,
|
|||
DynamicSubRequest::DynamicSubRequest(const DynamicSubRequest& other,
|
||||
DynamicRequest* owner) :
|
||||
_static_subrequest(other._static_subrequest), _owner(owner),
|
||||
_queue_position(other._queue_position)
|
||||
_queue_position(other._queue_position), _ran_for(other._ran_for),
|
||||
_state(other._state)
|
||||
{
|
||||
assert(owner != NULL);
|
||||
|
||||
|
@ -74,11 +76,6 @@ DynamicSubRequest::get_resource_key() const
|
|||
return _static_subrequest->get_resource_key();
|
||||
}
|
||||
|
||||
unsigned int
|
||||
DynamicSubRequest::get_places() const
|
||||
{
|
||||
return _static_subrequest->get_places();
|
||||
}
|
||||
|
||||
unsigned int
|
||||
DynamicSubRequest::get_length() const
|
||||
|
@ -106,6 +103,41 @@ DynamicSubRequest::get_request()
|
|||
}
|
||||
|
||||
|
||||
DynamicSubRequest::state
|
||||
DynamicSubRequest::get_state() const
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
|
||||
DynamicSubRequest::state
|
||||
DynamicSubRequest::set_state(state new_state)
|
||||
{
|
||||
state temp;
|
||||
_state = new_state;
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
DynamicSubRequest::get_remaining_time() const
|
||||
{
|
||||
return _static_subrequest->get_length() - _ran_for;
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
DynamicSubRequest::decrease_remaining_time()
|
||||
{
|
||||
assert(_state == Request::state_allocated);
|
||||
unsigned int temp = get_remaining_time();
|
||||
if(temp > 0)
|
||||
_ran_for++;
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DynamicSubRequest::serialize(SerializeVisitor& translator) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue