Wayverb
threaded_engine.h
1 #pragma once
2 
3 #include "combined/full_run.h"
4 #include "combined/model/persistent.h"
5 
6 #include "waveguide/mesh_descriptor.h"
7 
8 #include <future>
9 
10 namespace wayverb {
11 namespace combined {
12 
25 
26 class complete_engine final {
27 public:
28  ~complete_engine() noexcept;
29 
30  void run(core::compute_context compute_context,
31  core::gpu_scene_data scene_data,
32  model::persistent persistent,
33  model::output output);
34 
35  bool is_running() const;
36 
37  void cancel();
38 
47  using begun = util::event<>;
48  using finished = util::event<>;
49 
50  engine_state_changed::connection connect_engine_state_changed(
51  engine_state_changed::callback_type);
52 
53  waveguide_node_positions_changed::connection
54  connect_waveguide_node_positions_changed(
55  waveguide_node_positions_changed::callback_type);
56 
57  waveguide_node_pressures_changed::connection
58  connect_waveguide_node_pressures_changed(
59  waveguide_node_pressures_changed::callback_type);
60 
62  connect_raytracer_reflections_generated(
63  raytracer_reflections_generated::callback_type);
64 
65  encountered_error::connection connect_encountered_error(
66  encountered_error::callback_type);
67 
68  begun::connection connect_begun(begun::callback_type);
69  finished::connection connect_finished(finished::callback_type);
70 
71 private:
72  void do_run(core::compute_context compute_context,
73  core::gpu_scene_data scene_data,
74  model::persistent persistent,
75  model::output output);
76 
77  engine_state_changed engine_state_changed_;
78  waveguide_node_positions_changed waveguide_node_positions_changed_;
79  waveguide_node_pressures_changed waveguide_node_pressures_changed_;
80  raytracer_reflections_generated raytracer_reflections_generated_;
81  encountered_error encountered_error_;
82  begun begun_;
83  finished finished_;
84 
85  std::atomic_bool is_running_{false};
86  std::atomic_bool keep_going_{true};
87 
88  std::future<void> future_;
89 };
90 
91 } // namespace combined
92 } // namespace wayverb
Definition: scene_data.h:13
Definition: persistent.h:17
Definition: output.h:18
Definition: capsule_base.h:9
invariant: device is a valid device for the context
Definition: common.h:13
Definition: threaded_engine.h:26
Definition: event.h:28