replicode
time_job.h
Go to the documentation of this file.
1 // time_job.h
2 //
3 // Author: Eric Nivel
4 //
5 // BSD license:
6 // Copyright (c) 2010, Eric Nivel
7 // All rights reserved.
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are met:
10 //
11 // - Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // - Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in the
15 // documentation and/or other materials provided with the distribution.
16 // - Neither the name of Eric Nivel nor the
17 // names of their contributors may be used to endorse or promote products
18 // derived from this software without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
21 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 // DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
24 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #ifndef time_job_h
32 #define time_job_h
33 
34 #include "group.h"
35 #include "pgm_overlay.h"
36 #include "CoreLibrary/debug.h"
37 
38 namespace r_exec {
39 
41  public _Object {
42 protected:
43  TimeJob(uint64_t target_time);
44 public:
45  uint64_t target_time; // absolute deadline; 0 means ASAP.
46  virtual bool update() = 0; // next_target: absolute deadline; 0 means no more waiting; return false to shutdown the time core.
47  virtual bool is_alive() const { return true; }
48  virtual bool shouldRunAgain() const { return false; }
49  virtual void report(int64_t lag) const;
50 };
51 
53  public TimeJob {
54 public:
56  UpdateJob(Group *g, uint64_t ijt);
57  bool update();
58  void report(int64_t lag) const;
59 };
60 
62  public TimeJob {
63 protected:
64  SignalingJob(View *v, uint64_t ijt);
65 public:
67  bool is_alive() const;
68 };
69 
71  public SignalingJob {
72 public:
74  bool update();
75  void report(int64_t lag) const;
76 };
77 
79  public SignalingJob {
80 public:
82  bool update();
83  void report(int64_t lag) const;
84 };
85 
87  public TimeJob {
88 public:
90  InjectionJob(View *v, uint64_t ijt);
91  bool update();
92  void report(int64_t lag) const;
93 };
94 
96  public TimeJob {
97 public:
99  EInjectionJob(View *v, uint64_t ijt);
100  bool update();
101  void report(int64_t lag) const;
102 };
103 
105  public TimeJob {
106 public:
108  double sln_change;
110  SaliencyPropagationJob(Code *o, double sln_change, double source_sln_thr, uint64_t ijt);
111  bool update();
112  void report(int64_t lag) const;
113 };
114 
116  public TimeJob {
117 public:
119  bool update();
120 };
121 
122 template<class M> class MonitoringJob:
123  public TimeJob {
124 public:
126  MonitoringJob(M *monitor, uint64_t deadline): TimeJob(deadline), monitor(monitor) {}
127  bool update() {
128  monitor->update(target_time);
129  return true;
130  }
131  virtual bool shouldRunAgain() const { return (target_time != 0); }
132  bool is_alive() const {
133  return monitor->is_alive();
134  }
135  void report(int64_t lag) const {
136  debug("monitoring job") << "late:" << lag << "us behind.";
137  }
138 };
139 
141  public TimeJob {
142 public:
144  PerfSamplingJob(uint64_t start, uint64_t period);
145  bool update();
146  bool shouldRunAgain() const { return true; }
147 };
148 }
149 
150 
151 #endif
Definition: time_job.h:86
Definition: time_job.h:70
Definition: time_job.h:104
MonitoringJob(M *monitor, uint64_t deadline)
Definition: time_job.h:126
Definition: base.h:75
bool shouldRunAgain() const
Definition: time_job.h:146
virtual bool shouldRunAgain() const
Definition: time_job.h:48
#define dll_export
Definition: dll.h:44
P< Group > group
Definition: time_job.h:55
Definition: _context.cpp:34
double source_sln_thr
Definition: time_job.h:109
uint64_t target_time
Definition: time_job.h:45
Definition: base.h:47
Definition: time_job.h:122
bool is_alive() const
Definition: time_job.h:132
Definition: group.h:49
Definition: time_job.h:61
void report(int64_t lag) const
Definition: time_job.h:135
Definition: time_job.h:140
Definition: view.h:47
virtual bool shouldRunAgain() const
Definition: time_job.h:131
Definition: time_job.h:40
virtual bool is_alive() const
Definition: time_job.h:47
P< Code > object
Definition: time_job.h:107
P< View > view
Definition: time_job.h:66
Definition: time_job.h:115
Definition: object.h:172
Definition: time_job.h:95
P< View > view
Definition: time_job.h:89
Definition: time_job.h:52
static const DebugStream debug(const std::string area)
Definition: debug.h:51
P< M > monitor
Definition: time_job.h:125
bool update()
Definition: time_job.h:127
double sln_change
Definition: time_job.h:108
P< View > view
Definition: time_job.h:98
uint64_t period
Definition: time_job.h:143
Definition: time_job.h:78