diff --git a/include/threaded_physics.hpp b/include/threaded_physics.hpp index c1a03d7..4bbb2a8 100644 --- a/include/threaded_physics.hpp +++ b/include/threaded_physics.hpp @@ -15,7 +15,8 @@ class threaded_physics { - struct add_mass {}; + struct add_mass + {}; struct add_spring { @@ -23,24 +24,25 @@ class threaded_physics size_t b; }; - struct clear_graph {}; + struct clear_graph + {}; using command = std::variant; struct physics_state { - #ifdef TRACY +#ifdef TRACY TracyLockable(std::mutex, command_mtx); - #else +#else std::mutex command_mtx; - #endif +#endif std::queue pending_commands; - #ifdef TRACY +#ifdef TRACY TracyLockable(std::mutex, data_mtx); - #else +#else std::mutex data_mtx; - #endif +#endif std::condition_variable_any data_ready_cnd; std::condition_variable_any data_consumed_cnd; Vector3 mass_center = Vector3Zero(); @@ -55,14 +57,17 @@ class threaded_physics }; private: + std::optional* const> thread_pool; std::thread physics; public: physics_state state; public: - explicit threaded_physics(const std::optional* const> thread_pool = std::nullopt) - : physics(physics_thread, std::ref(state), std::ref(thread_pool)) {} + explicit threaded_physics( + const std::optional* const> _thread_pool = std::nullopt) + : thread_pool(_thread_pool), physics(physics_thread, std::ref(state), std::ref(thread_pool)) + {} threaded_physics(const threaded_physics& copy) = delete; auto operator=(const threaded_physics& copy) -> threaded_physics& = delete; @@ -78,17 +83,19 @@ public: } private: - #ifdef ASYNC_OCTREE +#ifdef ASYNC_OCTREE static auto set_octree_pool_thread_name(size_t idx) -> void; - #endif +#endif - static auto physics_thread(physics_state& state, std::optional* const> thread_pool) -> void; + static auto physics_thread(physics_state& state, + std::optional* const> thread_pool) -> void; public: auto clear_cmd() -> void; auto add_mass_cmd() -> void; auto add_spring_cmd(size_t a, size_t b) -> void; - auto add_mass_springs_cmd(size_t num_masses, const std::vector>& springs) -> void; + auto add_mass_springs_cmd(size_t num_masses, + const std::vector>& springs) -> void; }; -#endif \ No newline at end of file +#endif