stubs to complete the scheduler interface draft

This commit is contained in:
Fischlurch 2013-09-01 23:29:57 +02:00
parent 3688cbe9a5
commit 7ba0ef92c8
5 changed files with 142 additions and 87 deletions

View file

@ -263,10 +263,12 @@ namespace engine {
JobKind getKind() const;
bool isValid() const;
/** provide a hash based Job ID */
friend lib::HashVal hash_value (Job const&);
};
size_t hash_value (Job const&);

View file

@ -39,6 +39,7 @@
#include "lib/error.hpp"
#include "lib/hash-value.h"
#include "lib/time/timevalue.hpp"
#include "backend/engine/scheduler-frontend.hpp"
//#include "include/dummy-player-facade.h"
//#include "include/display-facade.h"
@ -51,6 +52,7 @@
//#include "lib/polymorphic-value.hpp"
//#include "lib/singleton.hpp"
//
#include <boost/noncopyable.hpp>
//#include <boost/scoped_ptr.hpp>
//#include <string>
@ -64,6 +66,7 @@ namespace engine {
// using lumiera::Display;
// using lumiera::DummyPlayer;
// using proc::play::Timings;
using lib::time::Time;
using lib::HashVal;
@ -136,6 +139,18 @@ namespace engine {
{
return is_scheduled_background (hash_value (job));
}
bool
has_job_scheduled_at (Time deadline)
{
UNIMPLEMENTED ("query for job scheduled for specific deadline");
}
Job const&
job_at (Time deadline)
{
UNIMPLEMENTED ("query for job scheduled for specific deadline");
}
};

View file

@ -28,7 +28,9 @@ namespace backend{
namespace engine {
/** */
/** storage for the (singleton) scheduler access frontend */
lib::Singleton<SchedulerFrontend> SchedulerFrontend::instance;

View file

@ -26,13 +26,16 @@
//using std::list;
#include "lib/singleton.hpp"
#include "lib/time/timevalue.hpp"
#include "backend/engine/job.h"
namespace backend{
namespace engine {
using lib::time::Time;
/**
* Access point to the scheduler service provided by the back-end.
@ -57,11 +60,98 @@ namespace engine {
* by the player. Client code should use the Player.
*/
static lib::Singleton<SchedulerFrontend> instance;
///// TODO: find out about the public operations
// note: the play controller lives in the proc-layer,
// but is a subsystem separate of the session.
/**
* Definition context for jobs to be scheduled.
* This builder allows to specify individual jobs,
* and to attach a transaction for prerequisite jobs.
* When done, the #commit operation can be used
* to activate all jobs defined this far.
*/
class JobTransaction
{
SchedulerFrontend* sched_;
JobTransaction (SchedulerFrontend* s)
: sched_(s)
{
UNIMPLEMENTED ("suitable representation, link to the actual scheduler?");
}
friend class SchedulerFrontend;
// using default copy operations
public:
/** finish this set of job definitions.
* All jobs attached to this transaction thus far,
* and all dependent transactions will be scheduled
* @note transaction should not be used beyond this point;
* contents and data structures are cleared right away;
*/
void
commit()
{
UNIMPLEMENTED ("feed all the attached jobs and transactions to the scheduler");
}
/** define a render job
* for time-bound calculation */
JobTransaction&
addJob (Time deadline, Job const& job)
{
UNIMPLEMENTED ("a mock implementation for adding a single job; change this later to talk to the real scheduler");
return *this;
}
/** define a job for background rendering. */
JobTransaction&
addBackground (Job const& job)
{
UNIMPLEMENTED ("a mock implementation for adding a single background job; change this later to talk to the real scheduler");
return *this;
}
/** define a render job
* to be calculated as soon as resources permit.
* Typically this call is used for rendering final results.
*/
JobTransaction&
addFreewheeling (Job const& job)
{
UNIMPLEMENTED ("a mock implementation for adding a single job for immediate calculation; change this later to talk to the real scheduler");
return *this;
}
JobTransaction&
attach (JobTransaction const& prerequisites)
{
UNIMPLEMENTED ("a mock implementation for adding a tree of prerequisite jobs; change this later to talk to the real scheduler");
return *this;
}
JobTransaction
startPrerequisiteTx()
{
UNIMPLEMENTED ("how to start a nested job definition context");
return JobTransaction(sched_);
}
};
JobTransaction
startJobTransaction()
{
return JobTransaction(this);
}
///// TODO: find out about further public operations
protected:
void activateTracing();

View file

@ -24,12 +24,12 @@
#include "lib/test/run.hpp"
#include "lib/util.hpp"
#include "proc/play/timings.hpp"
#include "lib/time/timevalue.hpp"
#include "backend/engine/job.h"
#include "backend/real-clock.hpp"
#include "backend/engine/scheduler-frontend.hpp"
#include "backend/engine/scheduler-diagnostics.hpp"
#include <boost/functional/hash.hpp>
namespace backend {
namespace engine {
@ -37,14 +37,10 @@ namespace test {
using util::isSameObject;
using lib::time::Time;
using lib::time::TimeVar;
using lib::time::Duration;
using lib::time::Offset;
using lib::time::FSecs;
using backend::engine::JobClosure;
using backend::engine::JobParameter;
namespace { // test fixture: a dummy job operation...
@ -78,7 +74,7 @@ namespace test {
size_t
hashOfInstance(InvocationInstanceID invoKey) const
{
UNIMPLEMENTED ("how to interpret the invoKey to create a hash value");
return boost::hash_value (invoKey.frameNumber);
}
};
@ -86,72 +82,22 @@ namespace test {
DummyClosure dummyClosure;
/**
* @todo this is a draft and shall be incorporated into the SchedulerFrontend
* Definition context for jobs to be scheduled.
* Allows to specify individual jobs, and to attach a transaction for prerequisite jobs
*/
class JobTransaction
{
public:
JobTransaction()
{
UNIMPLEMENTED ("suitable representation, link to the actual scheduler?");
}
// using default copy operations
/** define a render job
* for time-bound calculation
*/
void
addJob (Time deadline, Job const& job)
{
UNIMPLEMENTED ("a mock implementation for adding a single job; change this later to talk to the real scheduler");
}
/** define a job for background rendering. */
void
addBackground (Job const& job)
{
UNIMPLEMENTED ("a mock implementation for adding a single background job; change this later to talk to the real scheduler");
}
/** define a render job
* to be calculated as soon as resources permit.
* Typically this call is used for rendering final results.
*/
void
addFreewheeling (Job const& job)
{
UNIMPLEMENTED ("a mock implementation for adding a single job for immediate calculation; change this later to talk to the real scheduler");
}
void
attach (JobTransaction const& prerequisites)
{
UNIMPLEMENTED ("a mock implementation for adding a tree of prerequisite jobs; change this later to talk to the real scheduler");
}
JobTransaction startPrerequisiteTx();
};
JobTransaction
JobTransaction::startPrerequisiteTx()
{
UNIMPLEMENTED ("how to start a nested job definition context");
}
TimeVar testStartTime(Time::ZERO);
Time TEST_START_TIME (backend::RealClock::now());
const Duration TEST_FRAME_DURATION(FSecs(1,2));
inline Offset
dummyFrameStart (uint frameNr)
{
return frameNr * TEST_FRAME_DURATION;
}
} //(End) test fixture
typedef SchedulerFrontend::JobTransaction JobTransaction;
/***************************************************************************
* @test verify and demonstrate the organisation of the high-level interface
@ -175,7 +121,7 @@ namespace test {
void
verify_simple_job_specification (SchedulerFronend& scheduler)
verify_simple_job_specification (SchedulerFrontend& scheduler)
{
SchedulerDiagnostics monitor(scheduler);
@ -183,11 +129,10 @@ namespace test {
invoKey.frameNumber = 111;
Job job(dummyClosure, invoKey, Time::ZERO);
Time deadline(TEST_START_TIME);
JobTransaction definitionContext;
scheduler.startJobTransaction()
.addJob(job)
.addJob(deadline, job)
.commit();
CHECK ( monitor.is_scheduled_timebound (job));
@ -197,7 +142,7 @@ namespace test {
void
verify_job_specification_variations (SchedulerFronend& scheduler)
verify_job_specification_variations (SchedulerFrontend& scheduler)
{
SchedulerDiagnostics monitor(scheduler);
@ -233,21 +178,21 @@ namespace test {
* @see HierarchyOrientationIndicator_test#demonstrate_tree_rebuilding
*/
void
demonstrate_nested_job_specification (SchedulerFronend& scheduler)
demonstrate_nested_job_specification (SchedulerFrontend& scheduler)
{
SchedulerDiagnostics monitor(scheduler);
JobTransaction startTx = scheduler.startJobTransaction();
uint dummyLevel = 5;
uint dummyLevel = 5;
specifyJobs (startTx, dummyLevel);
startTx.commit();
for (uint i=0; i <=5; ++i)
{
Time nominalTime(dummyLevel*TEST_FRAME_DURATION);
Time deadline(testStartTime + i*TEST_FRAME_DURATION);
Time nominalTime(dummyFrameStart (i));
Time deadline(TEST_START_TIME + nominalTime);
CHECK (monitor.has_job_scheduled_at (deadline));
CHECK (isSameObject (dummyClosure, monitor.job_at(deadline).jobClosure));
@ -263,11 +208,12 @@ namespace test {
static void
specifyJobs (JobTransaction& currentTx, uint dummyLevel)
{
uint frameNr = dummyLevel;
InvocationInstanceID invoKey;
invoKey.frameNumber = dummyLevel;
invoKey.frameNumber = frameNr;
Time nominalTime(dummyLevel*TEST_FRAME_DURATION);
Time deadline(testStartTime + dummyLevel*TEST_FRAME_DURATION);
Time nominalTime(dummyFrameStart(frameNr));
Time deadline(TEST_START_TIME + nominalTime);
Job job(dummyClosure, invoKey, nominalTime);