88 template<
typename Derived>
143 template<typename... Args>
149 error_codes::common_errors::already_exists,
150 std::string(derived().component_name()) +
" is already running",
151 "startable_base::do_start",
152 std::string(derived().component_name()));
157 auto result =
derived().do_start_impl(std::forward<Args>(args)...);
186 bool expected =
false;
188 std::memory_order_acq_rel))
193 auto result =
derived().do_stop_impl();
244 return static_cast<Derived&
>(*this);
251 [[nodiscard]]
auto derived() const -> const Derived&
253 return static_cast<const Derived&
>(*this);
Thread-safe lifecycle state management for network components.
auto try_start() -> bool
Attempts to transition from stopped to running state.
auto mark_stopped() -> void
Marks the component as stopped and signals waiters.
auto is_running() const -> bool
Checks if the component is currently running.
auto wait_for_stop() -> void
Blocks until the component has stopped.
CRTP base class providing unified start/stop lifecycle management.
auto do_stop() -> VoidResult
Unified stop operation with lifecycle management.
auto is_stop_initiated() const noexcept -> bool
Checks if stop has been initiated.
auto is_running() const noexcept -> bool
Checks if the component is currently running.
auto do_start(Args &&... args) -> VoidResult
Unified start operation with lifecycle management.
auto get_lifecycle() const -> const lifecycle_manager &
Gets the lifecycle manager (const version).
auto derived() -> Derived &
CRTP accessor for derived class.
auto wait_for_stop() -> void
Blocks until stop is called.
~startable_base()=default
Destructor.
auto derived() const -> const Derived &
CRTP accessor for derived class (const version).
startable_base(const startable_base &)=delete
startable_base()=default
Default constructor.
startable_base & operator=(const startable_base &)=delete
auto get_lifecycle() -> lifecycle_manager &
Gets the lifecycle manager for derived class access.
startable_base(startable_base &&) noexcept=default
auto reset_connection_state() -> void
Resets connection state flags for a fresh start.
std::atomic< bool > stop_initiated_
lifecycle_manager lifecycle_
Component lifecycle management (start, stop, restart).
Utility components for network_system.
Network-specific error and result type definitions.