replicode
pgm_controller.h
Go to the documentation of this file.
1 // pgm_controller.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 pgm_controller_h
32 #define pgm_controller_h
33 
34 #include "pgm_overlay.h"
35 
36 
37 namespace r_exec {
38 
40  public OController {
41 protected:
42  bool run_once;
43 
44  _PGMController(r_code::View *ipgm_view);
45  virtual ~_PGMController();
46 public:
47  Code *get_core_object() const {
48  return getObject()->get_reference(0);
49  }
50 };
51 
52 // TimeCores holding InputLessPGMSignalingJob trigger the injection of the productions.
53 // No overlays.
55  public _PGMController {
56 public:
59 
61  void signal_input_less_pgm();
62 
63 private:
64  std::mutex m_hostMutex;
65 };
66 
67 // Controller for programs with inputs.
69  public _PGMController {
70 public:
71  PGMController(r_code::View *ipgm_view);
72  virtual ~PGMController();
73 
74  void take_input(r_exec::View *input);
75  void reduce(r_exec::View *input);
76 
77  void notify_reduction();
78 };
79 
80 // Signaled by TimeCores (holding AntiPGMSignalingJob).
81 // Possible recursive locks: signal_anti_pgm()->overlay->inject_productions()->mem->inject()->injectNow()->inject_reduction_jobs()->overlay->take_input().
83  public _PGMController {
84 private:
86  std::mutex m_hostMutex;
87 
88  void push_new_signaling_job();
89 public:
90  AntiPGMController(r_code::View *ipgm_view);
92 
93  void take_input(r_exec::View *input);
94  void reduce(r_exec::View *input);
95  void signal_anti_pgm();
96 
98  void restart();
99 };
100 }
101 
102 #endif
virtual Code * get_reference(uint16_t i) const =0
#define dll_export
Definition: dll.h:44
Definition: pgm_controller.h:39
Definition: _context.cpp:34
Definition: pgm_controller.h:68
std::mutex m_hostMutex
Definition: pgm_controller.h:64
Definition: overlay.h:172
Definition: pgm_controller.h:54
Definition: view.h:47
bool run_once
Definition: pgm_controller.h:42
Definition: pgm_controller.h:82
std::mutex m_hostMutex
Definition: pgm_controller.h:86
Definition: object.h:100
Definition: object.h:172
void reduce(const IPGMContext &context, const IPGMContext &input_set, const IPGMContext &section, std::vector< uint16_t > &input_indices, std::vector< uint16_t > &production_indices)
Definition: context.cpp:523
Code * get_core_object() const
Definition: pgm_controller.h:47
bool successful_match
Definition: pgm_controller.h:85