Lumiera  0.pre.03
»edit your freedom«
job.h
Go to the documentation of this file.
1 /*
2  JOB.h - render job closure
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 
51 #ifndef VAULT_GEAR_JOB_H
52 #define VAULT_GEAR_JOB_H
53 
54 
55 #include "lib/llist.h"
56 #include "lib/hash-value.h"
57 #include "lib/time.h"
58 
59 
60 
62  {
63  DONE,
69  };
70 
71 enum JobKind
72  {
77  };
78 
80  {
85  };
86 
87 
88 typedef int64_t FrameCnt;
89 
90 
91 
98 struct lumiera_jobClosure { /* placeholder */ };
99 typedef struct lumiera_jobClosure* LumieraJobClosure;
100 
101 
102 
113  {
114  lumiera_uid luid{0};
115 
116  /* ----- alternative accessors for test code ---- */
117  FrameCnt frameNumber;
118  struct { int32_t a,b;
119  int64_t t;
120  } part;
121  struct {
122  uint64_t w1;
123  uint64_t w2;
124  } code;
125  };
126 
127 
128 
129 
135  {
136  gavl_time_t nominalTime;
137  InvocationInstanceID invoKey;
141  };
142 typedef struct lumiera_jobParameter_struct lumiera_jobParameter;
143 typedef lumiera_jobParameter* LumieraJobParameter;
144 
145 
148  {
149  LumieraJobClosure jobClosure;
150  lumiera_jobParameter parameter;
151  };
152 typedef struct lumiera_jobDefinition_struct lumiera_jobDefinition;
153 typedef lumiera_jobDefinition* LumieraJobDefinition;
154 
155 
173  {
174  gavl_time_t deadline;
175  JobState jobState;
176 
177  lumiera_jobDefinition jobDefinition;
178 
179  /* == Job prerequisites == */
180  LList waiting;
181  LList failed;
182  LList completed;
183  };
184 typedef struct lumiera_jobDescriptor_struct lumiera_jobDescriptor;
185 typedef lumiera_jobDescriptor* LumieraJobDescriptor;
186 
187 
188 
189 
190 
191 
192 
193 
194 #ifdef __cplusplus /* ============== C++ Interface ================= */
195 
196 #include "lib/nocopy.hpp"
197 #include <string>
198 
199 
200 
201 namespace vault{
202 namespace gear {
203 
204  using lib::time::TimeValue;
205  using lib::time::Time;
206  using lib::HashVal;
207 
208  typedef lumiera_jobParameter const& JobParameter;
209 
210 
212  class JobFunctor
213  : util::NonCopyable // ....has distinct identity and stable address
214  {
215  public:
216  virtual ~JobFunctor();
217 
218  virtual std::string
219  diagnostic() const
220  {
221  return "JobFunctor";
222  }
223 
224  operator std::string() const
225  {
226  return diagnostic();
227  }
228  };
245  : public lumiera_jobClosure
246  , public JobFunctor
247  {
248  public:
249  virtual ~JobClosure();
250 
251 
252  virtual void invokeJobOperation (JobParameter parameter) =0;
253 
254  virtual JobKind getJobKind() const =0;
255  virtual HashVal hashOfInstance(InvocationInstanceID) const =0;
256  virtual InvocationInstanceID buildInstanceID(HashVal)const =0;
257 
258  lib::HashVal hash_value (JobParameter) const;
259  };
260 
261 
262 
263 
277  class Job
278  : public lumiera_jobDefinition
279  {
280 
281  public:
282 
283  Job (JobClosure& specificJobDefinition
284  ,InvocationInstanceID invoKey
285  ,Time nominalFrameTime)
286  {
287  this->jobClosure = &specificJobDefinition;
288  this->parameter.nominalTime = _raw(nominalFrameTime);
289  this->parameter.invoKey = invoKey;
290  }
291 
292  // using standard copy operations
293 
294 
295  void triggerJob() const;
296 
297 
298  Time
299  getNominalTime() const
300  {
301  return Time (TimeValue(parameter.nominalTime));
302  }
303 
305  getInvocationInstanceID() const
306  {
307  return this->parameter.invoKey;
308  }
309 
310  JobKind getKind() const;
311 
312  bool usesClosure (JobClosure const&) const;
313 
315  friend lib::HashVal hash_value (Job const&);
316  };
317 
318  inline bool
319  operator== (Job const& left, Job const& right)
320  {
321  return hash_value (left) == hash_value (right);
322  }
323 
324  inline bool
325  operator!= (Job const& left, Job const& right)
326  {
327  return hash_value (left) != hash_value (right);
328  }
329 
330 
331 
332 
333 
334 }} // namespace vault::gear
335 
336 
337 
338 
339 extern "C" {
340 #endif /* =========================== C Interface ===================== */
341 
342 
345 void lumiera_job_invoke (LumieraJobDefinition);
346 
348 size_t lumiera_job_get_hash (LumieraJobDefinition);
349 
350 int lumiera_invokey_eq (void* l, void* r);
351 
352 
353 #ifdef __cplusplus
354 }
355 #endif
356 #endif /*VAULT_GEAR_JOB_H*/
lumiera_jobDefinition jobDefinition
of interest only to Steam-Layer
Definition: job.h:177
LumieraJobClosure jobClosure
type and context of the job, including the actual functor
Definition: job.h:149
waiting for some prerequisite
Definition: job.h:65
Common functions for handling of time values.
invocation parameter for the individual frame calculation job.
Definition: job.h:134
closure representing the execution context of a job.
Definition: job.h:98
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
job is currently running
Definition: job.h:64
Description of a job.
Definition: job.h:172
complete definition of an individual job
Definition: job.h:147
accessing prerequisites, IO bound
Definition: job.h:74
background rendering job
Definition: job.h:84
got aborted
Definition: job.h:68
gavl_time_t deadline
given in real wall clock time
Definition: job.h:174
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:308
lumiera_jobParameter parameter
the "moving parts" for this individual invocation (Job)
Definition: job.h:150
size_t lumiera_job_get_hash(LumieraJobDefinition)
calculate a hash value based on the Job&#39;s identity.
Definition: job.cpp:153
regular job scheduled for time-bound delivery
Definition: job.h:81
JobKind
Definition: job.h:71
Definition: job.h:82
Mix-Ins to allow or prohibit various degrees of copying and cloning.
sorry, can&#39;t do that Dave
Definition: job.h:66
job for freewheeling calculation of final results
Definition: job.h:83
calculating frame data, CPU bound
Definition: job.h:73
deadline expired
Definition: job.h:67
test and diagnostic and research
Definition: job.h:76
opaque ID attached to each individual job invocation.
Definition: job.h:112
Hash value types and utilities.
Intrusive cyclic double linked list There is only one node type which contains a forward and a backwa...
size_t HashVal
a STL compatible hash value
Definition: hash-value.h:56
JobPriority
Definition: job.h:79
Interface of the closure for frame rendering jobs.
Definition: job.h:244
void lumiera_job_invoke(LumieraJobDefinition)
trigger execution of a specific job, assuming availability of all prerequisites
Definition: job.cpp:146
unsigned char lumiera_uid[16]
storage for a Lumiera unique ID, based on a 128bit random number
Definition: hash-value.h:45
render process self organisation
Definition: job.h:75
Individual frame rendering task, forwarding to a closure.
Definition: job.h:277
basic constant internal time value.
Definition: timevalue.hpp:142
mission accomplished
Definition: job.h:63
Vault-Layer implementation namespace root.
JobState
Definition: job.h:61