|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Thread-safe connection state management. More...
#include <connection_state.h>

Public Member Functions | |
| connection_state ()=default | |
| Default constructor. Initializes to disconnected state. | |
| ~connection_state ()=default | |
| Destructor. | |
| connection_state (const connection_state &)=delete | |
| connection_state & | operator= (const connection_state &)=delete |
| connection_state (connection_state &&other) noexcept | |
| connection_state & | operator= (connection_state &&other) noexcept |
| auto | status () const -> connection_status |
| Gets the current connection status. | |
| auto | is_connected () const -> bool |
| Checks if currently connected. | |
| auto | is_disconnected () const -> bool |
| Checks if currently disconnected. | |
| auto | is_connecting () const -> bool |
| Checks if connection is in progress. | |
| auto | is_disconnecting () const -> bool |
| Checks if disconnection is in progress. | |
| auto | set_connecting () -> bool |
| Attempts to transition from disconnected to connecting. | |
| auto | set_connected () -> void |
| Transitions to connected state. | |
| auto | set_disconnecting () -> bool |
| Attempts to transition from connected to disconnecting. | |
| auto | set_disconnected () -> void |
| Transitions to disconnected state. | |
| auto | reset () -> void |
| Resets to disconnected state. | |
Private Attributes | |
| std::atomic< connection_status > | status_ {connection_status::disconnected} |
Thread-safe connection state management.
This utility class encapsulates connection state tracking with proper atomic operations for thread safety. It provides state machine semantics for connection lifecycle.
All methods use atomic operations and are safe for concurrent access.
Definition at line 72 of file connection_state.h.
|
default |
Default constructor. Initializes to disconnected state.
|
default |
Destructor.
|
delete |
|
inlinenoexcept |
Definition at line 90 of file connection_state.h.
References kcenon::network::utils::disconnected.
|
inlinenodiscard |
Checks if currently connected.
Definition at line 122 of file connection_state.h.
References kcenon::network::utils::connected, and status_.
|
inlinenodiscard |
Checks if connection is in progress.
Definition at line 140 of file connection_state.h.
References kcenon::network::utils::connecting, and status_.
|
inlinenodiscard |
Checks if currently disconnected.
Definition at line 131 of file connection_state.h.
References kcenon::network::utils::disconnected, and status_.
|
inlinenodiscard |
Checks if disconnection is in progress.
Definition at line 149 of file connection_state.h.
References kcenon::network::utils::disconnecting, and status_.
|
inlinenoexcept |
Definition at line 97 of file connection_state.h.
References kcenon::network::utils::disconnected, and status_.
|
delete |
|
inline |
Resets to disconnected state.
Alias for set_disconnected() for clarity.
Definition at line 201 of file connection_state.h.
References set_disconnected().

|
inline |
Transitions to connected state.
Should only be called after successful connection.
Definition at line 170 of file connection_state.h.
References kcenon::network::utils::connected, and status_.
|
inlinenodiscard |
Attempts to transition from disconnected to connecting.
Definition at line 158 of file connection_state.h.
References kcenon::network::utils::connecting, kcenon::network::utils::disconnected, and status_.
|
inline |
Transitions to disconnected state.
Can be called from any state to force disconnection.
Definition at line 191 of file connection_state.h.
References kcenon::network::utils::disconnected, and status_.
Referenced by reset().

|
inlinenodiscard |
Attempts to transition from connected to disconnecting.
Definition at line 179 of file connection_state.h.
References kcenon::network::utils::connected, kcenon::network::utils::disconnecting, and status_.
|
inlinenodiscard |
Gets the current connection status.
Definition at line 113 of file connection_state.h.
References status_.
|
private |
Definition at line 204 of file connection_state.h.
Referenced by is_connected(), is_connecting(), is_disconnected(), is_disconnecting(), operator=(), set_connected(), set_connecting(), set_disconnected(), set_disconnecting(), and status().