MyraMath
Job.h
Go to the documentation of this file.
1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
6 #ifndef MYRAMATH_JOBGRAPH_JOB_H
7 #define MYRAMATH_JOBGRAPH_JOB_H
8 
14 #include <myramath/MYRAMATH_EXPORT.h>
15 
17 
18 #include <set>
19 #include <string>
20 #include <stdint.h>
21 
22 namespace myra {
23 
25 class MYRAMATH_EXPORT Job
26  {
27  public:
28 
30  Job() { P = 0; }
31 
33  virtual JobID id() const { throw std::runtime_error("Job::id() not implemented"); }
34 
36  virtual void parents(JobIDs& output) const { throw std::runtime_error("Job::parents(JobIDs&) not implemented"); }
37 
39  virtual void children(JobIDs& output) const { throw std::runtime_error("Job::children(JobIDs&) not implemented"); }
40 
42  bool notify(const JobID& j);
43 
45  virtual uint64_t execute() { return 0; }
46 
48  virtual std::string name() const { return "Job"; }
49 
51  virtual ~Job() {}
52 
53  private:
54 
55  // Used to track how many parent Job's are still pending.
56  int P;
57 
58  };
59 
60 } // namespace myra
61 
62 #endif
Abstraction to represent one node of a JobGraph.
Definition: Job.h:25
virtual ~Job()
Virtual destructor, for subtypes to release resources.
Definition: Job.h:51
Job()
Default constructor.
Definition: Job.h:30
Definition: syntax.dox:1
virtual uint64_t execute()
Subtypes inject the "real work" here. Should return the amount of "work" performed.
Definition: Job.h:45
virtual JobID id() const
Returns the JobID of this Job.
Definition: Job.h:33
Key type used to identify the Job&#39;s of a JobGraph.
Key type used to identify the Job&#39;s of a JobGraph.
Definition: JobID.h:60
virtual void children(JobIDs &output) const
Returns the JobIDs of children - successor Jobs that can only execute() after this one...
Definition: Job.h:39
virtual std::string name() const
Returns a printable name for this Job, for debugging.
Definition: Job.h:48
std::vector< JobID > JobIDs
Useful typedef.
Definition: JobID.h:118
virtual void parents(JobIDs &output) const
Returns the JobIDs of parents - predecessor Jobs that must execute() before this one.
Definition: Job.h:36