11#include "../utility/utility.hpp"
14#include "../macros.hpp"
24namespace hi {
inline namespace v1 {
38hi_no_inline
typename T::value_type start_subsystem(
40 typename T::value_type off_value,
73 hi_assert(std::popcount(std::to_underlying(
state_bit)) == 1);
77 hilet lock = std::scoped_lock(subsystem_mutex);
118 typename T::value_type off_value,
180 typename T::value_type off_value,
187 hi_assert(
tmp != off_value);
206 hilet lock = std::scoped_lock(detail::subsystem_mutex);
232 detail::subsystem_mutex.lock();
233 global_state |= global_state_type::system_is_shutting_down;
235 while (!detail::subsystem_deinit_list.empty()) {
236 auto deinit =
std::move(detail::subsystem_deinit_list.back());
237 hi_assert_not_null(deinit);
238 detail::subsystem_deinit_list.pop_back();
240 detail::subsystem_mutex.unlock();
242 detail::subsystem_mutex.lock();
244 detail::subsystem_mutex.unlock();
An atomic access global variable for quick access to state of the system.
unfair_recursive_mutex subsystem_mutex
Mutex to be held when writing to system_status or accessing system_status_deinit_list.
Definition subsystem.hpp:35
std::vector< void(*)()> subsystem_deinit_list
A list of deinit function to be called on shutdown.
Definition subsystem.hpp:29
Definition of the unfair_recursive_mutex.
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:260
bool is_system_running() noexcept
Check if the HikoGUI system is running.
Definition global_state.hpp:209
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:178
void shutdown_system() noexcept
Shutdown the system.
Definition subsystem.hpp:230
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:116
std::atomic< global_state_type > global_state
The global state of the hikogui framework.
Definition global_state.hpp:201
global_state_type
The flag-type used for global state.
Definition global_state.hpp:30
void stop_subsystem(void(*deinit_function)())
Stop a sub-system.
Definition subsystem.hpp:202
void start_system() noexcept
Start the system.
Definition subsystem.hpp:217
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
An unfair recursive-mutex This is a fast implementation of a recursive-mutex which does not fairly ar...
Definition unfair_recursive_mutex.hpp:38