Lumiera  0.pre.03
»edit your freedom«
job-ticket.cpp
Go to the documentation of this file.
1 /*
2  JobTicket - execution plan for render jobs
3 
4  Copyright (C) Lumiera.org
5  2012, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
35 #include "lib/depend.hpp"
36 #include "lib/util.hpp"
37 
38 
39 namespace steam {
40 namespace engine {
41 
42  using vault::gear::Job;
44  using lib::HashVal;
45  using lib::unConst;
46  using lib::time::FSecs;
47 
48 
49  namespace { // Details...
51 
52  /* ======== hard wired =================*/
53  const FSecs JOB_MINIMUM_RUNTIME{1,1000};
54 
55  } // (END) Details...
56 
57 
58 
59 
60 
63 
65  : provision_{nopFunctor(), ExitNode::NIL}
66  { }
67 
68 
78  Job
80  {
81  if (this->empty())
82  {
83  return Job(nopFunctor(), InvocationInstanceID(), nominalTime);
84  }
85  else
86  {
87  REQUIRE (this->isValid(), "Attempt to generate render job for incomplete or unspecified render plan.");
88  JobClosure& functor = static_cast<JobClosure&> (unConst(provision_.jobFunctor));
89  InvocationInstanceID invoKey{timeHash (nominalTime, provision_.invocationSeed)};
90 
91  return Job(functor, invoKey, nominalTime);
92  }
93  }
94 
95 
101  Duration
103  {
104  if (this->empty())
105  return Duration{JOB_MINIMUM_RUNTIME};
106  else
107  {
108  REQUIRE (isValid(), "Attempt to determine timings for incomplete or unspecified render plan.");
109  return provision_.exitNode.getUpperBoundRuntime();
110  }
111  }
112 
113 
118  JobTicket::timeHash (Time nominalTime, InvocationInstanceID const& seed)
119  {
120  InvocationInstanceID res{seed};
121  HashVal timeMark = res.part.t;
122  lib::hash::combine (timeMark, hash_value (nominalTime));
123  res.part.t = timeMark;
124  return res;
125  }
126 
127 
128  namespace {
129  inline bool
130  operator== (InvocationInstanceID const& l, InvocationInstanceID const& r)
131  {
132  return lumiera_invokey_eq (unConst(&l), unConst(&r));
133  }
134  }
135 
139  bool
140  JobTicket::verifyInstance (JobFunctor& functor, InvocationInstanceID const& invoKey, Time nominalTime) const
141  {
142  return util::isSameObject (provision_.jobFunctor, functor)
143  and invoKey == timeHash (nominalTime, provision_.invocationSeed);
144  }
145 
146 
147 
148 
149 }} // namespace steam::engine
bool verifyInstance(JobFunctor &, InvocationInstanceID const &, Time) const
Helper for tests: verify the given invocation parameters match this JobTicket.
Definition: job-ticket.cpp:140
Execution plan to generate render jobs within a specific render process.
Generic implementation of a JobFunctor to perform no calculations.
void combine(size_t &combinedHash, size_t additionalHash)
meld the additional hash value into the given base hash value.
Definition: hash-value.h:71
Steam-Layer implementation namespace root.
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
static JobTicket NOP
special »do nothing« JobTicket marker
Definition: job-ticket.hpp:136
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:308
static InvocationInstanceID timeHash(Time, InvocationInstanceID const &)
Tag the precomputed invocation ID with the nominal frame time.
Definition: job-ticket.cpp:118
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:229
Singleton services and Dependency Injection.
opaque ID attached to each individual job invocation.
Definition: job.h:112
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:56
Interface of the closure for frame rendering jobs.
Definition: job.h:244
Duration is the internal Lumiera time metric.
Definition: timevalue.hpp:477
Individual frame rendering task, forwarding to a closure.
Definition: job.h:277
static ExitNode NIL
storage for the »inactive« ExitNode marker
Definition: exit-node.hpp:103
execution plan for pulling a specific exit node.
Definition: job-ticket.hpp:87
Duration getExpectedRuntime()
Core operation: guess expected runtime for rendering.
Definition: job-ticket.cpp:102
Job createJobFor(Time nominalTime)
Core operation: build a concrete render job based on this blueprint.
Definition: job-ticket.cpp:79