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)
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 
42 #ifndef VAULT_GEAR_JOB_H
43 #define VAULT_GEAR_JOB_H
44 
45 
46 #include "lib/llist.h"
47 #include "lib/hash-value.h"
48 #include "lib/time.h"
49 
50 
51 
53  {
54  DONE,
60  };
61 
62 enum JobKind
63  {
68  };
69 
71  {
76  };
77 
78 
79 typedef int64_t FrameCnt;
80 
81 
82 
89 struct lumiera_jobClosure { /* placeholder */ };
90 typedef struct lumiera_jobClosure* LumieraJobClosure;
91 
92 
93 
104  {
105  lumiera_uid luid{0};
106 
107  /* ----- alternative accessors for test code ---- */
108  FrameCnt frameNumber;
109  struct { int32_t a,b;
110  int64_t t;
111  } part;
112  struct {
113  uint64_t w1;
114  uint64_t w2;
115  } code;
116  };
117 
118 
119 
120 
126  {
127  gavl_time_t nominalTime;
128  InvocationInstanceID invoKey;
132  };
133 typedef struct lumiera_jobParameter_struct lumiera_jobParameter;
134 typedef lumiera_jobParameter* LumieraJobParameter;
135 
136 
139  {
140  LumieraJobClosure jobClosure;
141  lumiera_jobParameter parameter;
142  };
143 typedef struct lumiera_jobDefinition_struct lumiera_jobDefinition;
144 typedef lumiera_jobDefinition* LumieraJobDefinition;
145 
146 
164  {
165  gavl_time_t deadline;
166  JobState jobState;
167 
168  lumiera_jobDefinition jobDefinition;
169 
170  /* == Job prerequisites == */
171  LList waiting;
172  LList failed;
173  LList completed;
174  };
175 typedef struct lumiera_jobDescriptor_struct lumiera_jobDescriptor;
176 typedef lumiera_jobDescriptor* LumieraJobDescriptor;
177 
178 
179 
180 
181 
182 
183 
184 
185 #ifdef __cplusplus /* ============== C++ Interface ================= */
186 
187 #include "lib/nocopy.hpp"
188 #include <string>
189 
190 
191 
192 namespace vault{
193 namespace gear {
194 
195  using lib::time::TimeValue;
196  using lib::time::Time;
197  using lib::HashVal;
198 
199  typedef lumiera_jobParameter const& JobParameter;
200 
201 
203  class JobFunctor
204  : util::NonCopyable // ....has distinct identity and stable address
205  {
206  public:
207  virtual ~JobFunctor();
208 
209  virtual std::string
210  diagnostic() const
211  {
212  return "JobFunctor";
213  }
214 
215  operator std::string() const
216  {
217  return diagnostic();
218  }
219  };
236  : public lumiera_jobClosure
237  , public JobFunctor
238  {
239  public:
240  virtual ~JobClosure();
241 
242 
243  virtual void invokeJobOperation (JobParameter parameter) =0;
244 
245  virtual JobKind getJobKind() const =0;
246  virtual HashVal hashOfInstance(InvocationInstanceID) const =0;
247  virtual InvocationInstanceID buildInstanceID(HashVal)const =0;
248 
249  lib::HashVal hash_value (JobParameter) const;
250  };
251 
252 
253 
254 
268  class Job
269  : public lumiera_jobDefinition
270  {
271 
272  public:
273 
274  Job (JobClosure& specificJobDefinition
275  ,InvocationInstanceID invoKey
276  ,Time nominalFrameTime)
277  {
278  this->jobClosure = &specificJobDefinition;
279  this->parameter.nominalTime = _raw(nominalFrameTime);
280  this->parameter.invoKey = invoKey;
281  }
282 
283  // using standard copy operations
284 
285 
286  void triggerJob() const;
287 
288 
289  Time
290  getNominalTime() const
291  {
292  return Time (TimeValue(parameter.nominalTime));
293  }
294 
296  getInvocationInstanceID() const
297  {
298  return this->parameter.invoKey;
299  }
300 
301  JobKind getKind() const;
302 
303  bool usesClosure (JobClosure const&) const;
304 
306  friend lib::HashVal hash_value (Job const&);
307  };
308 
309  inline bool
310  operator== (Job const& left, Job const& right)
311  {
312  return hash_value (left) == hash_value (right);
313  }
314 
315  inline bool
316  operator!= (Job const& left, Job const& right)
317  {
318  return hash_value (left) != hash_value (right);
319  }
320 
321 
322 
323 
324 
325 }} // namespace vault::gear
326 
327 
328 
329 
330 extern "C" {
331 #endif /* =========================== C Interface ===================== */
332 
333 
336 void lumiera_job_invoke (LumieraJobDefinition);
337 
339 size_t lumiera_job_get_hash (LumieraJobDefinition);
340 
341 int lumiera_invokey_eq (void* l, void* r);
342 
343 
344 #ifdef __cplusplus
345 }
346 #endif
347 #endif /*VAULT_GEAR_JOB_H*/
lumiera_jobDefinition jobDefinition
of interest only to Steam-Layer
Definition: job.h:168
LumieraJobClosure jobClosure
type and context of the job, including the actual functor
Definition: job.h:140
waiting for some prerequisite
Definition: job.h:56
Common functions for handling of time values.
invocation parameter for the individual frame calculation job.
Definition: job.h:125
closure representing the execution context of a job.
Definition: job.h:89
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
job is currently running
Definition: job.h:55
Description of a job.
Definition: job.h:163
complete definition of an individual job
Definition: job.h:138
accessing prerequisites, IO bound
Definition: job.h:65
background rendering job
Definition: job.h:75
got aborted
Definition: job.h:59
gavl_time_t deadline
given in real wall clock time
Definition: job.h:165
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:299
lumiera_jobParameter parameter
the "moving parts" for this individual invocation (Job)
Definition: job.h:141
size_t lumiera_job_get_hash(LumieraJobDefinition)
calculate a hash value based on the Job&#39;s identity.
Definition: job.cpp:144
regular job scheduled for time-bound delivery
Definition: job.h:72
JobKind
Definition: job.h:62
Definition: job.h:73
Mix-Ins to allow or prohibit various degrees of copying and cloning.
sorry, can&#39;t do that Dave
Definition: job.h:57
job for freewheeling calculation of final results
Definition: job.h:74
calculating frame data, CPU bound
Definition: job.h:64
deadline expired
Definition: job.h:58
test and diagnostic and research
Definition: job.h:67
opaque ID attached to each individual job invocation.
Definition: job.h:103
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:52
JobPriority
Definition: job.h:70
Interface of the closure for frame rendering jobs.
Definition: job.h:235
void lumiera_job_invoke(LumieraJobDefinition)
trigger execution of a specific job, assuming availability of all prerequisites
Definition: job.cpp:137
unsigned char lumiera_uid[16]
storage for a Lumiera unique ID, based on a 128bit random number
Definition: hash-value.h:40
render process self organisation
Definition: job.h:66
Individual frame rendering task, forwarding to a closure.
Definition: job.h:268
basic constant internal time value.
Definition: timevalue.hpp:133
mission accomplished
Definition: job.h:54
Vault-Layer implementation namespace root.
JobState
Definition: job.h:52