11#include "../utility/utility.hpp"
14#include "../macros.hpp"
22hi_export_module(hikogui.concurrency.subsystem);
25hi_export
namespace hi {
inline namespace v1 {
39hi_no_inline
typename T::value_type start_subsystem(
41 typename T::value_type off_value,
74 hi_assert(std::popcount(std::to_underlying(
state_bit)) == 1);
78 auto const lock = std::scoped_lock(subsystem_mutex);
119 typename T::value_type off_value,
181 typename T::value_type off_value,
188 hi_assert(
tmp != off_value);
207 auto const lock = std::scoped_lock(detail::subsystem_mutex);
233 detail::subsystem_mutex.lock();
234 global_state |= global_state_type::system_is_shutting_down;
236 while (!detail::subsystem_deinit_list.empty()) {
237 auto deinit =
std::move(detail::subsystem_deinit_list.back());
238 hi_assert_not_null(deinit);
239 detail::subsystem_deinit_list.pop_back();
241 detail::subsystem_mutex.unlock();
243 detail::subsystem_mutex.lock();
245 detail::subsystem_mutex.unlock();
An atomic access global variable for quick access to state of the system.
hi_inline unfair_recursive_mutex subsystem_mutex
Mutex to be held when writing to system_status or accessing system_status_deinit_list.
Definition subsystem.hpp:36
hi_inline std::vector< void(*)()> subsystem_deinit_list
A list of deinit function to be called on shutdown.
Definition subsystem.hpp:30
Definition of the unfair_recursive_mutex.
hi_inline bool is_system_running() noexcept
Check if the HikoGUI system is running.
Definition global_state.hpp:211
hi_inline void stop_subsystem(void(*deinit_function)())
Stop a sub-system.
Definition subsystem.hpp:203
T::value_type start_subsystem_or_terminate(T &check_variable, typename T::value_type off_value, typename T::value_type(*init_function)(), void(*deinit_function)())
Start a sub-system.
Definition subsystem.hpp:179
hi_inline std::atomic< global_state_type > global_state
The global state of the hikogui framework.
Definition global_state.hpp:203
T::value_type start_subsystem(T &check_variable, typename T::value_type off_value, typename T::value_type(*init_function)(), void(*deinit_function)())
Start a sub-system.
Definition subsystem.hpp:117
hi_inline void shutdown_system() noexcept
Shutdown the system.
Definition subsystem.hpp:231
hi_inline void start_system() noexcept
Start the system.
Definition subsystem.hpp:218
global_state_type
The flag-type used for global state.
Definition global_state.hpp:32
hi_inline bool global_state_enable(global_state_type subsystem, std::memory_order order=std::memory_order::seq_cst) noexcept
Enable a subsystem.
Definition global_state.hpp:262
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
An unfair recursive-mutex This is a fast implementation of a recursive-mutex which does not fairly ar...
Definition unfair_recursive_mutex.hpp:42