AERA
mem.h
1 //_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
2 //_/_/
3 //_/_/ AERA
4 //_/_/ Autocatalytic Endogenous Reflective Architecture
5 //_/_/
6 //_/_/ Copyright (c) 2018-2025 Jeff Thompson
7 //_/_/ Copyright (c) 2018-2025 Kristinn R. Thorisson
8 //_/_/ Copyright (c) 2018-2025 Icelandic Institute for Intelligent Machines
9 //_/_/ http://www.iiim.is
10 //_/_/
11 //_/_/ Copyright (c) 2010-2012 Eric Nivel
12 //_/_/ Center for Analysis and Design of Intelligent Agents
13 //_/_/ Reykjavik University, Menntavegur 1, 102 Reykjavik, Iceland
14 //_/_/ http://cadia.ru.is
15 //_/_/
16 //_/_/ Part of this software was developed by Eric Nivel
17 //_/_/ in the HUMANOBS EU research project, which included
18 //_/_/ the following parties:
19 //_/_/
20 //_/_/ Autonomous Systems Laboratory
21 //_/_/ Technical University of Madrid, Spain
22 //_/_/ http://www.aslab.org/
23 //_/_/
24 //_/_/ Communicative Machines
25 //_/_/ Edinburgh, United Kingdom
26 //_/_/ http://www.cmlabs.com/
27 //_/_/
28 //_/_/ Istituto Dalle Molle di Studi sull'Intelligenza Artificiale
29 //_/_/ University of Lugano and SUPSI, Switzerland
30 //_/_/ http://www.idsia.ch/
31 //_/_/
32 //_/_/ Institute of Cognitive Sciences and Technologies
33 //_/_/ Consiglio Nazionale delle Ricerche, Italy
34 //_/_/ http://www.istc.cnr.it/
35 //_/_/
36 //_/_/ Dipartimento di Ingegneria Informatica
37 //_/_/ University of Palermo, Italy
38 //_/_/ http://diid.unipa.it/roboticslab/
39 //_/_/
40 //_/_/
41 //_/_/ --- HUMANOBS Open-Source BSD License, with CADIA Clause v 1.0 ---
42 //_/_/
43 //_/_/ Redistribution and use in source and binary forms, with or without
44 //_/_/ modification, is permitted provided that the following conditions
45 //_/_/ are met:
46 //_/_/ - Redistributions of source code must retain the above copyright
47 //_/_/ and collaboration notice, this list of conditions and the
48 //_/_/ following disclaimer.
49 //_/_/ - Redistributions in binary form must reproduce the above copyright
50 //_/_/ notice, this list of conditions and the following disclaimer
51 //_/_/ in the documentation and/or other materials provided with
52 //_/_/ the distribution.
53 //_/_/
54 //_/_/ - Neither the name of its copyright holders nor the names of its
55 //_/_/ contributors may be used to endorse or promote products
56 //_/_/ derived from this software without specific prior
57 //_/_/ written permission.
58 //_/_/
59 //_/_/ - CADIA Clause: The license granted in and to the software
60 //_/_/ under this agreement is a limited-use license.
61 //_/_/ The software may not be used in furtherance of:
62 //_/_/ (i) intentionally causing bodily injury or severe emotional
63 //_/_/ distress to any person;
64 //_/_/ (ii) invading the personal privacy or violating the human
65 //_/_/ rights of any person; or
66 //_/_/ (iii) committing or preparing for any act of war.
67 //_/_/
68 //_/_/ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
69 //_/_/ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
70 //_/_/ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
71 //_/_/ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
72 //_/_/ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
73 //_/_/ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
74 //_/_/ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
75 //_/_/ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
76 //_/_/ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
77 //_/_/ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
78 //_/_/ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
79 //_/_/ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80 //_/_/ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
81 //_/_/ OF SUCH DAMAGE.
82 //_/_/
83 //_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
84 
85 #ifndef mem_h
86 #define mem_h
87 
88 #include <sstream>
89 #include "reduction_core.h"
90 #include "time_core.h"
91 #include "pgm_overlay.h"
92 #include "binding_map.h"
93 #include "dll.h"
94 
95 #include <list>
96 #include <deque>
97 #include <atomic>
98 
99 #include "../r_code/list.h"
100 #include "../r_comp/segments.h"
101 
102 #include "../submodules/CoreLibrary/CoreLibrary/pipe.h"
103 
104 
105 namespace r_exec {
106 
117 class r_exec_dll _Mem :
118  public r_code::Mem {
119 public:
120  typedef enum {
121  NOT_STARTED = 0,
122  RUNNING = 1,
123  STOPPED = 2
124  }State;
125 protected:
126  // Parameters::Init.
127  std::chrono::microseconds base_period_;
128  uint32 reduction_core_count_;
129  uint32 time_core_count_;
130 
131  // Parameters::System.
132  float32 mdl_inertia_sr_thr_;
133  uint32 mdl_inertia_cnt_thr_;
134  float32 tpx_dsr_thr_;
135  std::chrono::microseconds min_sim_time_horizon_;
136  std::chrono::microseconds max_sim_time_horizon_;
137  float32 sim_time_horizon_factor_;
138  std::chrono::microseconds tpx_time_horizon_;
139  std::chrono::microseconds perf_sampling_period_;
140  float32 float_tolerance_;
141  std::chrono::microseconds time_tolerance_;
142  std::chrono::microseconds primary_thz_;
143  std::chrono::microseconds secondary_thz_;
144 
145  // Parameters::Debug.
146  bool debug_;
147  uint32 ntf_mk_res_;
148  uint32 goal_pred_success_res_;
149  bool keep_invalidated_objects_;
150 
151  // Parameters::Run.
152  uint32 probe_level_;
153 
154  PipeNN<P<_ReductionJob>, 1024> *reduction_job_queue_;
155  PipeNN<P<TimeJob>, 1024> *time_job_queue_;
156  ReductionCore **reduction_cores_;
157  TimeCore **time_cores_;
158 
159  // Performance stats.
160  uint32 reduction_job_count_;
161  std::chrono::microseconds reduction_job_avg_latency_; // latency: popping time.-pushing time; the lower the better.
162  std::chrono::microseconds _reduction_job_avg_latency_; // previous value.
163  uint32 time_job_count_;
164  std::chrono::microseconds time_job_avg_latency_; // latency: deadline-the time the job is popped from the pipe; if <0, not registered (as it is too late for action); the higher the better.
165  std::chrono::microseconds _time_job_avg_latency_; // previous value.
166 
167  CriticalSection time_jobCS_;
168  CriticalSection reduction_jobCS_;
169 
170  uint32 core_count_;
171  CriticalSection core_countCS_;
172 
173  State state_;
174  CriticalSection stateCS_;
175  Semaphore *stop_sem_; // blocks the rMem until all cores terminate.
176 
177  r_code::list<P<r_code::Code> > objects_; // store objects in order of injection: holds the initial objects (and dynamically created ones if MemStatic is used).
178 
179  P<Group> root_; // holds everything.
180  r_code::Code *stdin_;
181  r_code::Code *stdout_;
182  r_code::Code *self_;
183 
184  void reset(); // clear the content of the mem.
185 
186  std::vector<Group *> initial_groups_; // convenience; cleared after start();
187 
188  void store(r_code::Code *object);
189  virtual void set_last_oid(int32 oid) = 0;
190  virtual void bind(View *view) = 0;
191 
192  bool deleted_;
193 
194  static const uint32 RUNTIME_OUTPUT_STREAM_COUNT = 10;
195  std::ostream *runtime_output_streams_[RUNTIME_OUTPUT_STREAM_COUNT];
196  // Use default_runtime_output_stream_ if runtime_output_streams_[i] is NULL. For no output,
197  // runtime_output_streams_[i] will be set to new NullOStream().
198  std::ostream *default_runtime_output_stream_;
199 
200  std::vector<P<r_code::Code> > axiom_values_;
201 
202  _Mem();
203 
204  static void _unpack_code(r_code::Code *hlp, uint16 fact_object_index, r_code::Code *fact_object, uint16 read_index);
205 public:
206  static _Mem *Get() { return (_Mem *)Mem::Get(); }
207 
208  typedef enum {
209  STDIN = 0,
210  STDOUT = 1
211  }STDGroupID;
212 
213  virtual ~_Mem();
214 
215  void init(std::chrono::microseconds base_period,
216  uint32 reduction_core_count,
217  uint32 time_core_count,
218  float32 mdl_inertia_sr_thr,
219  uint32 mdl_inertia_cnt_thr,
220  float32 tpx_dsr_thr,
221  std::chrono::microseconds min_sim_time_horizon,
222  std::chrono::microseconds max_sim_time_horizon,
223  float32 sim_time_horizon_factor,
224  std::chrono::microseconds tpx_time_horizon,
225  std::chrono::microseconds perf_sampling_period,
226  float32 float_tolerance,
227  std::chrono::microseconds time_tolerance,
228  std::chrono::microseconds primary_thz,
229  std::chrono::microseconds secondary_thz,
230  bool debug,
231  uint32 ntf_mk_res,
232  uint32 goal_pred_success_res,
233  uint32 probe_level,
234  uint32 traces,
235  bool keep_invalidated_objects);
236 
237  State get_state() const { return state_; }
242  std::chrono::microseconds get_sampling_period() const { return 2 * base_period_; }
243  uint64 get_probe_level() const { return probe_level_; }
244  uint32 get_reduction_core_count() const { return reduction_core_count_; }
245  uint32 get_time_core_count() const { return time_core_count_; }
246  float32 get_mdl_inertia_sr_thr() const { return mdl_inertia_sr_thr_; }
247  uint32 get_mdl_inertia_cnt_thr() const { return mdl_inertia_cnt_thr_; }
248  float32 get_tpx_dsr_thr() const { return tpx_dsr_thr_; }
249  std::chrono::microseconds get_min_sim_time_horizon() const { return min_sim_time_horizon_; }
250  std::chrono::microseconds get_max_sim_time_horizon() const { return max_sim_time_horizon_; }
251  std::chrono::microseconds get_sim_time_horizon(std::chrono::microseconds horizon) const {
252  return std::chrono::microseconds((int64)(horizon.count() * sim_time_horizon_factor_));
253  }
254  std::chrono::microseconds get_tpx_time_horizon() const { return tpx_time_horizon_; }
255  std::chrono::microseconds get_primary_thz() const { return primary_thz_; }
256  std::chrono::microseconds get_secondary_thz() const { return secondary_thz_; }
257 
258  bool get_debug() const { return debug_; }
259  uint32 get_ntf_mk_res() const { return ntf_mk_res_; }
260  uint32 get_goal_pred_success_res(Group *host, Timestamp now, Timestamp::duration time_to_live) const {
261 
262  if (debug_)
263  return goal_pred_success_res_;
264  if (time_to_live.count() == 0)
265  return 1;
266  return r_code::Utils::GetResilience(now, time_to_live, host->get_upr());
267  }
268 
269  r_code::Code *get_root() const;
270  r_code::Code *get_stdin() const;
271  r_code::Code *get_stdout() const;
272  r_code::Code *get_self() const;
273 
274  State check_state(); // called by delegates after waiting in case stop() is called in the meantime.
275  void start_core(); // called upon creation of a delegate.
276  void shutdown_core(); // called upon completion of a delegate's task.
277 
278  virtual bool load(const std::vector<r_code::Code *> *objects, uint32 stdin_oid, uint32 stdout_oid, uint32 self_oid); // call before start; no mod/set/eje will be executed (only inj);
279  // return false on error.
280  Timestamp start(); // return the starting time.
281 
294  void run_in_diagnostic_time(std::chrono::milliseconds run_time);
295  static Timestamp diagnostic_time_now_;
296  static Timestamp get_diagnostic_time_now();
297  // Tell an inheriting class (with inject) when the time is changed.
298  virtual void on_diagnostic_time_tick();
299  void stop(); // after stop() the content is cleared and one has to call load() and start() again.
300 
301  // Internal core processing ////////////////////////////////////////////////////////////////
302 
303  P<_ReductionJob> pop_reduction_job(bool waitForItem = true);
304  void push_reduction_job(_ReductionJob *j);
305  P<TimeJob> pop_time_job(bool waitForItem = true);
306  void push_time_job(TimeJob *j);
307 
313  void inject_from_io_device(View *view);
314 
330  View* inject_marker_value_from_io_device(
331  r_code::Code* obj, r_code::Code* prop, Atom val, Timestamp after, Timestamp before,
332  View::SyncMode sync_mode, r_code::Code* group);
333 
349  View* inject_marker_value_from_io_device(
350  r_code::Code* obj, r_code::Code* prop, std::vector<Atom> val, Timestamp after, Timestamp before,
351  View::SyncMode sync_mode, r_code::Code* group);
352 
368  r_code::Code* obj, r_code::Code* prop, Atom val, Timestamp after, Timestamp before,
369  View::SyncMode sync_mode)
370  {
371  return inject_marker_value_from_io_device(obj, prop, val, after, before, sync_mode, get_stdin());
372  }
373 
389  r_code::Code* obj, r_code::Code* prop, Atom val, Timestamp after, Timestamp before, r_code::Code* group)
390  {
391  return inject_marker_value_from_io_device(
392  obj, prop, val, after, before, View::SYNC_PERIODIC, group);
393  }
394 
409  r_code::Code* obj, r_code::Code* prop, Atom val, Timestamp after, Timestamp before)
410  {
411  return inject_marker_value_from_io_device(
412  obj, prop, val, after, before, View::SYNC_PERIODIC, get_stdin());
413  }
414 
431  View* inject_marker_value_from_io_device(
432  r_code::Code* obj, r_code::Code* prop, r_code::Code* val, Timestamp after, Timestamp before,
433  View::SyncMode sync_mode, r_code::Code* group);
434 
451  r_code::Code* obj, r_code::Code* prop, r_code::Code* val, Timestamp after, Timestamp before,
452  View::SyncMode sync_mode)
453  {
454  return inject_marker_value_from_io_device(obj, prop, val, after, before, sync_mode, get_stdin());
455  }
456 
473  r_code::Code* obj, r_code::Code* prop, r_code::Code* val, Timestamp after, Timestamp before, r_code::Code* group)
474  {
475  return inject_marker_value_from_io_device(
476  obj, prop, val, after, before, View::SYNC_PERIODIC, group);
477  }
478 
494  r_code::Code* obj, r_code::Code* prop, r_code::Code* val, Timestamp after, Timestamp before)
495  {
496  return inject_marker_value_from_io_device(
497  obj, prop, val, after, before, View::SYNC_PERIODIC, get_stdin());
498  }
499 
516  View* inject_marker_value_from_io_device(
517  r_code::Code* obj, r_code::Code* prop, const std::string& val, Timestamp after, Timestamp before,
518  View::SyncMode sync_mode, r_code::Code* group);
519 
536  r_code::Code* obj, r_code::Code* prop, const std::string& val, Timestamp after, Timestamp before,
537  View::SyncMode sync_mode)
538  {
539  return inject_marker_value_from_io_device(obj, prop, val, after, before, sync_mode, get_stdin());
540  }
541 
558  r_code::Code* obj, r_code::Code* prop, const std::string& val, Timestamp after, Timestamp before, r_code::Code* group)
559  {
560  return inject_marker_value_from_io_device(obj, prop, val, after, before, View::SYNC_PERIODIC, group);
561  }
562 
578  r_code::Code* obj, r_code::Code* prop, const std::string& val, Timestamp after, Timestamp before)
579  {
580  return inject_marker_value_from_io_device(obj, prop, val, after, before, View::SYNC_PERIODIC, get_stdin());
581  }
582 
600  r_code::Code* obj, r_code::Code* prop, const std::vector<r_code::Code*>& val,
601  Timestamp after, Timestamp before, View::SyncMode sync_mode, r_code::Code* group);
602 
619  r_code::Code* obj, r_code::Code* prop, const std::vector<r_code::Code*>& val,
620  Timestamp after, Timestamp before, View::SyncMode sync_mode)
621  {
622  return inject_marker_value_from_io_device(obj, prop, val, after, before, sync_mode, get_stdin());
623  }
624 
641  r_code::Code* obj, r_code::Code* prop, const std::vector<r_code::Code*>& val,
642  Timestamp after, Timestamp before, r_code::Code* group)
643  {
644  return inject_marker_value_from_io_device(
645  obj, prop, val, after, before, View::SYNC_PERIODIC, group);
646  }
647 
663  r_code::Code* obj, r_code::Code* prop, const std::vector<r_code::Code*>& val,
664  Timestamp after, Timestamp before)
665  {
666  return inject_marker_value_from_io_device(
667  obj, prop, val, after, before, View::SYNC_PERIODIC, get_stdin());
668  }
669 
687  r_code::Code* obj, r_code::Code* prop, uint16 opcode, const std::vector<r_code::Atom>& vals,
688  Timestamp after, Timestamp before, View::SyncMode sync_mode, r_code::Code* group);
689 
706  r_code::Code* obj, r_code::Code* prop, uint16 opcode, const std::vector<r_code::Atom>& vals,
707  Timestamp after, Timestamp before, View::SyncMode sync_mode)
708  {
709  return inject_marker_value_from_io_device(obj, prop, opcode, vals, after, before, sync_mode, get_stdin());
710  }
711 
728  r_code::Code* obj, r_code::Code* prop, uint16 opcode, const std::vector<r_code::Atom>& vals,
729  Timestamp after, Timestamp before, r_code::Code* group)
730  {
731  return inject_marker_value_from_io_device(
732  obj, prop, opcode, vals, after, before, View::SYNC_PERIODIC, group);
733  }
734 
750  r_code::Code* obj, r_code::Code* prop, uint16 opcode, const std::vector<r_code::Atom>& vals,
751  Timestamp after, Timestamp before)
752  {
753  return inject_marker_value_from_io_device(
754  obj, prop, opcode, vals, after, before, View::SYNC_PERIODIC, get_stdin());
755  }
756 
770  View* inject_fact_from_io_device(
771  r_code::Code* object, Timestamp after, Timestamp before, View::SyncMode sync_mode,
772  r_code::Code* group);
773 
786  View* inject_fact_from_io_device(r_code::Code* object, Timestamp after, Timestamp before, r_code::Code* group) {
787  return inject_fact_from_io_device(
788  object, after, before, View::SYNC_PERIODIC, group);
789  }
790 
791  // Called upon successful reduction.
801  void inject(View *view, bool is_from_io_device = false);
802  void inject_async(View *view);
803  void inject_new_object(View *view);
804  void inject_existing_object(View *view, r_code::Code *object, Group *host);
805  void inject_null_program(Controller *c, Group *group, std::chrono::microseconds time_to_live, bool take_past_inputs); // build a view v (ijt=now, act=1, sln=0, res according to time_to_live in the group), attach c to v, inject v in the group.
806  void inject_hlps(std::vector<View *> views, Group *destination);
807  void inject_notification(View *view, bool lock);
808  virtual r_code::Code *check_existence(r_code::Code *object) = 0; // returns the existing object if any, or object otherwise: in the latter case, packing may occur.
809 
810  void propagate_sln(r_code::Code *object, float32 change, float32 source_sln_thr);
811 
812  // Called by groups.
813  void inject_copy(View *view, Group *destination); // for cov; NB: no cov for groups, r-groups, models, pgm or notifications.
814 
815  // Called by cores.
816  void register_reduction_job_latency(std::chrono::microseconds latency);
817  void register_time_job_latency(std::chrono::microseconds latency);
818  void inject_perf_stats();
819 
820  // rMem to rMem.
821  // The view must contain the destination group (either stdin or stdout) as its grp member.
822  // To be redefined by object transport aware subcalsses.
823  virtual void eject(View *view, uint16 node_id);
824 
834  virtual r_code::Code* eject(r_code::Code *command);
835 
836  virtual r_code::Code *_build_object(Atom head) const = 0;
837  virtual r_code::Code *build_object(Atom head) const = 0;
838 
839  // unpacking of high-level patterns: upon loading or reception.
840  static void unpack_hlp(r_code::Code *hlp);
841  static r_code::Code *unpack_fact(r_code::Code *hlp, uint16 fact_index);
842  static r_code::Code *unpack_fact_object(r_code::Code *hlp, uint16 fact_object_index);
843 
844  // packing of high-level patterns: upon dynamic generation or transmission.
845  void pack_hlp(r_code::Code *hlp) const;
846  static void pack_fact(r_code::Code *fact, r_code::Code *hlp, uint16 &write_index, std::vector<P<r_code::Code> > *references);
847  static void pack_fact_object(r_code::Code *fact_object, r_code::Code *hlp, uint16 &write_index, std::vector<P<r_code::Code> > *references);
848 
855  static r_code::Code* find_object(
856  const std::vector<r_code::Code *> *objects, const char* name);
857 
858  r_code::Code *clone(r_code::Code *original) const; // shallow copy.
859 
860  // External device I/O ////////////////////////////////////////////////////////////////
861  virtual r_comp::Image *get_objects(bool include_invalidated = false) = 0; // create an image; fill with all objects; call only when stopped.
862  r_comp::Image *get_models(); // create an image; fill with all models; call only when stopped.
863 
869  bool matches_axiom(r_code::Code* obj);
870 
879  static void init_timestamps(Timestamp time_reference, const r_code::list<P<r_code::Code>>& objects);
880 
881  //std::vector<uint64> timings_report; // debug facility.
882 
887  void set_default_runtime_output_stream(std::ostream *default_runtime_output_stream) {
888  default_runtime_output_stream_ = default_runtime_output_stream;
889  }
890 
898  static std::ostream &Output(TraceLevel l);
899 };
900 
905 public:
912  DiagnosticTimeState(_Mem* mem, std::chrono::milliseconds run_time);
913 
918  bool step();
919 private:
920  _Mem* mem_;
921  std::chrono::milliseconds run_time_;
922  TimeJob::Compare time_job_compare_;
923  size_t n_reduction_jobs_this_sampling_period_;
924  std::vector<P<_ReductionJob>> reduction_job_queue_;
925  size_t reduction_job_queue_index_;
926  // Use a deque so we can efficiently remove from the front.
927  std::deque<P<TimeJob>> ordered_time_job_queue_;
928  Timestamp tick_time_;
929  Timestamp end_time_;
930  int pass_number_;
931  bool need_diagnostic_time_tick_;
932 };
933 
934 
935 // _Mem that stores the objects as long as they are not invalidated.
936 class r_exec_dll MemStatic :
937  public _Mem {
938 private:
939  CriticalSection objectsCS_; // protects last_oid_ and objects_.
940  uint32 last_oid_;
941  void bind(View *view) override; // assigns an oid, stores view->object in objects if needed.
942  void set_last_oid(int32 oid) override;
943 protected:
944  MemStatic();
945 public:
946  virtual ~MemStatic();
947 
948  void delete_object(r_code::Code *object) override; // erase the object from objects if needed.
949  // return an image containing valid objects, or all objects if include_invalidated.
950  r_comp::Image *get_objects(bool include_invalidated = false) override;
951 };
952 
953 // _Mem that does not store objects.
954 class r_exec_dll MemVolatile :
955  public _Mem {
956 private:
957  std::atomic_int32_t last_oid_;
958  uint32 get_oid();
959  void bind(View *view) override; // assigns an oid (atomic operation).
960  void set_last_oid(int32 oid) override;
961 protected:
962  MemVolatile();
963 public:
964  virtual ~MemVolatile();
965 
966  void delete_object(r_code::Code* /* object */) override {}
967 
968  r_comp::Image *get_objects(bool /* include_invalidated */) override { return NULL; }
969 };
970 
978 template<class O, class S> class MemExec :
979  public S {
980 public:
981  MemExec();
982  virtual ~MemExec();
983 
984  // Called at load time.
985  r_code::Code *build_object(r_code::SysObject *source) const override;
986 
987  // Called at runtime.
988  r_code::Code *_build_object(Atom head) const override;
989  r_code::Code *build_object(Atom head) const override;
990 
991  // Executive device functions ////////////////////////////////////////////////////////
992 
993  r_code::Code *check_existence(r_code::Code *object) override;
994 
995  // Called by the communication device (I/O).
996  void inject(O *object, View *view);
997 };
998 
999 }
1000 
1001 #include "mem.tpl.cpp"
1002 
1003 #endif
r_exec::DiagnosticTimeState::DiagnosticTimeState
DiagnosticTimeState(_Mem *mem, std::chrono::milliseconds run_time)
Definition: mem.cpp:535
r_exec::MemStatic
Definition: mem.h:937
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, Atom val, Timestamp after, Timestamp before, View::SyncMode sync_mode)
Definition: mem.h:367
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, const std::string &val, Timestamp after, Timestamp before, View::SyncMode sync_mode)
Definition: mem.h:535
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, r_code::Code *val, Timestamp after, Timestamp before, r_code::Code *group)
Definition: mem.h:472
r_exec::DiagnosticTimeState
Definition: mem.h:904
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, r_code::Code *val, Timestamp after, Timestamp before)
Definition: mem.h:493
r_exec::_Mem::get_sampling_period
std::chrono::microseconds get_sampling_period() const
Definition: mem.h:242
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, uint16 opcode, const std::vector< r_code::Atom > &vals, Timestamp after, Timestamp before, View::SyncMode sync_mode, r_code::Code *group)
r_code::Atom
Definition: atom.h:104
core::PipeNN
Definition: pipe.h:151
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, const std::vector< r_code::Code * > &val, Timestamp after, Timestamp before, View::SyncMode sync_mode)
Definition: mem.h:618
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, const std::vector< r_code::Code * > &val, Timestamp after, Timestamp before, View::SyncMode sync_mode, r_code::Code *group)
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, uint16 opcode, const std::vector< r_code::Atom > &vals, Timestamp after, Timestamp before)
Definition: mem.h:749
r_code::SysObject
Definition: r_code/object.h:136
core::P
Definition: base.h:103
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, uint16 opcode, const std::vector< r_code::Atom > &vals, Timestamp after, Timestamp before, r_code::Code *group)
Definition: mem.h:727
r_code::Code
Definition: r_code/object.h:224
r_exec::_Mem::inject_fact_from_io_device
View * inject_fact_from_io_device(r_code::Code *object, Timestamp after, Timestamp before, r_code::Code *group)
Definition: mem.h:786
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, Atom val, Timestamp after, Timestamp before)
Definition: mem.h:408
core::CriticalSection
Definition: submodules/CoreLibrary/CoreLibrary/utils.h:233
r_exec::TimeCore
Definition: time_core.h:111
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, Atom val, Timestamp after, Timestamp before, r_code::Code *group)
Definition: mem.h:388
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, const std::vector< r_code::Code * > &val, Timestamp after, Timestamp before)
Definition: mem.h:662
r_exec::View
Definition: view.h:102
r_exec::Group
Definition: group.h:108
r_exec::_Mem::set_default_runtime_output_stream
void set_default_runtime_output_stream(std::ostream *default_runtime_output_stream)
Definition: mem.h:887
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, const std::string &val, Timestamp after, Timestamp before, r_code::Code *group)
Definition: mem.h:557
r_comp::Image
Definition: segments.h:177
core::Semaphore
Definition: submodules/CoreLibrary/CoreLibrary/utils.h:208
r_code::Mem
Definition: r_code/object.h:420
r_exec::MemVolatile
Definition: mem.h:955
r_exec::Controller
Definition: controller.h:104
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, const std::string &val, Timestamp after, Timestamp before)
Definition: mem.h:577
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, const std::vector< r_code::Code * > &val, Timestamp after, Timestamp before, r_code::Code *group)
Definition: mem.h:640
r_code::list
Definition: list.h:99
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, r_code::Code *val, Timestamp after, Timestamp before, View::SyncMode sync_mode)
Definition: mem.h:450
r_exec::_Mem
Definition: mem.h:118
r_exec::TimeJob::Compare
Definition: time_job.h:110
r_exec::_Mem::inject_marker_value_from_io_device
View * inject_marker_value_from_io_device(r_code::Code *obj, r_code::Code *prop, uint16 opcode, const std::vector< r_code::Atom > &vals, Timestamp after, Timestamp before, View::SyncMode sync_mode)
Definition: mem.h:705
r_exec::DiagnosticTimeState::step
bool step()
Definition: mem.cpp:547
r_exec::MemExec
Definition: mem.h:979
r_exec::ReductionCore
Definition: reduction_core.h:105