Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
job-ticket.hpp
Go to the documentation of this file.
1/*
2 JOB-TICKET.hpp - execution plan for render jobs
3
4 Copyright (C)
5 2012, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
26#ifndef STEAM_ENGINE_JOB_TICKET_H
27#define STEAM_ENGINE_JOB_TICKET_H
28
29#include "steam/common.hpp"
30#include "vault/gear/job.h"
34#include "lib/util-foreach.hpp"
35#include "lib/iter-adapter.hpp"
36#include "lib/itertools.hpp"
37#include "lib/util.hpp"
38
39#include <utility>
40#include <stack>
41
42
43namespace steam {
44namespace engine {
45
51using lib::time::Time;
52using util::isnil;
53using lib::HashVal;
54using lib::LUID;
55
56
80 {
83 {
84 Prerequisite* next{nullptr}; // for intrusive list
86
87 template<class ALO>
88 Prerequisite (ExitNode const& node, ALO& allocateTicket)
89 : prereqTicket{allocateTicket (node, allocateTicket)}
90 { }
91 };
93
94
96 struct Provision
97 {
102
103 Provision (JobFunctor& func, ExitNode const& node, HashVal seed =0)
104 : jobFunctor{func}
105 , exitNode{node}
106 , invocationSeed(static_cast<JobClosure&>(func).buildInstanceID(seed))
107 { }
108 };
109
112
113
114 JobTicket();
115
116 template<class ALO>
117 static Provision buildProvisionSpec (ExitNode const&, ALO&);
118
119
120
121 public:
122 template<class ALO>
123 JobTicket (ExitNode const& exitNode, ALO& allocator)
124 : provision_{buildProvisionSpec (exitNode, allocator)}
125 { }
126
128
129
130 bool
131 empty() const
132 {
133 return isnil (provision_.exitNode);
134 }
135
136 bool
137 isValid() const
138 {
139 if (empty()) return false;
140
142 return not lumiera_invokey_eq (&util::unConst(provision_).invocationSeed, &empty)
145 ,[](auto& pq){ return pq.prereqTicket.isValid(); });
146 }
147
148
154 auto
156 {
159 ,[](Prerequisite& prq) -> JobTicket&
160 {
161 return prq.prereqTicket;
162 });
163 }
164
168 Job createJobFor (Time nominalTime);
169
174
175
176 protected:
178 bool verifyInstance (JobFunctor&, InvocationInstanceID const&, Time) const;
179
180 };
181
182
183
184
185
202 template<class ALO>
203 inline JobTicket::Provision
204 JobTicket::buildProvisionSpec (ExitNode const& exitNode, ALO& allocTicket)
205 {
206 REQUIRE (not isnil (exitNode)); // has valid functor
207 HashVal invoSeed = exitNode.getPipelineIdentity();
208 JobFunctor& func = exitNode.getInvocationFunctor();
209 Provision provisionSpec{func, exitNode, invoSeed};
210 for (ExitNode const& preNode: exitNode.getPrerequisites())
211 provisionSpec.prerequisites.emplace(preNode, allocTicket);
212 return provisionSpec;
213 }
214
215
216
217}}// namespace steam::engine
218#endif /*STEAM_ENGINE_JOB_TICKET_H*/
Intrusive single linked list, possibly taking ownership of node elements.
IterStateWrapper< IterationState, N & > iterator
Duration is the internal Lumiera time metric.
Lumiera's internal time value datatype.
A top-level point in the render node network where data generation can be driven.
Definition exit-node.hpp:65
HashVal getPipelineIdentity() const
auto getPrerequisites() const
JobFunctor & getInvocationFunctor() const
execution plan for pulling a specific exit node.
Duration getExpectedRuntime()
Core operation: guess expected runtime for rendering.
Job createJobFor(Time nominalTime)
Core operation: build a concrete render job based on this blueprint.
bool verifyInstance(JobFunctor &, InvocationInstanceID const &, Time) const
Helper for tests: verify the given invocation parameters match this JobTicket.
static Provision buildProvisionSpec(ExitNode const &, ALO &)
static JobTicket NOP
special »do nothing« JobTicket marker
static InvocationInstanceID timeHash(Time, InvocationInstanceID const &)
Tag the precomputed invocation ID with the nominal frame time.
JobTicket(ExitNode const &exitNode, ALO &allocator)
auto getPrerequisites()
Core operation: iterate over the prerequisites, required to carry out a render operation based on thi...
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
Interface of the closure for frame rendering jobs.
Definition job.h:244
Individual frame rendering task, forwarding to a closure.
Definition job.h:276
Effective top-level exit point to pull rendered data from the nodes network.
Helper template(s) for creating Lumiera Forward Iterators.
Helpers for working with iterators based on the pipeline model.
int lumiera_invokey_eq(void *l, void *r)
Definition job.cpp:154
Definition of a render job.
opaque ID attached to each individual job invocation.
Definition job.h:105
Intrusive single linked list with optional ownership.
auto transformIterator(IT const &src, FUN processingFunc)
Build a TransformIter: convenience free function shortcut, picking up the involved types automaticall...
size_t HashVal
a STL compatible hash value
Definition hash-value.h:52
lumiera_uid * LUID
a Lumiera UID
Definition hash-value.h:55
Steam-Layer implementation namespace root.
bool and_all(IT i, IT end, FUN predicate)
All quantification: check if all elements of a collection satisfy the given predicate.
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
Definition util.hpp:358
bool isnil(lib::time::Duration const &dur)
Basic set of definitions and includes commonly used together.
Prerequisite(ExitNode const &node, ALO &allocateTicket)
InvocationInstanceID invocationSeed
Provision(JobFunctor &func, ExitNode const &node, HashVal seed=0)
a family of time value like entities and their relationships.
Perform operations "for each element" of a collection.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...