|
PACS System 0.1.0
PACS DICOM system library
|
#include <accept_worker.h>


Public Types | |
| using | result_void = common::VoidResult |
| using | connection_callback = std::function<void(uint64_t session_id)> |
| Callback type for new connection events. | |
| using | maintenance_callback = std::function<void()> |
| Callback type for periodic maintenance tasks. | |
Public Member Functions | |
| accept_worker (uint16_t port, connection_callback on_connection, maintenance_callback on_maintenance=nullptr) | |
| Constructs an accept_worker with the specified configuration. | |
| ~accept_worker () override | |
| Destructor. | |
| accept_worker (const accept_worker &)=delete | |
| accept_worker & | operator= (const accept_worker &)=delete |
| accept_worker (accept_worker &&)=delete | |
| accept_worker & | operator= (accept_worker &&)=delete |
| void | set_max_pending_connections (int backlog) |
| Sets the maximum number of pending connections in the listen queue. | |
| uint16_t | port () const noexcept |
| Gets the configured port number. | |
| int | max_pending_connections () const noexcept |
| Gets the current backlog setting. | |
| bool | is_accepting () const noexcept |
| Checks if the worker is actively accepting connections. | |
| std::string | to_string () const override |
| Gets a string representation of the worker state. | |
Protected Member Functions | |
| result_void | before_start () override |
| Initializes resources before the worker thread starts. | |
| result_void | do_work () override |
| Main work routine - checks for incoming connections. | |
| result_void | after_stop () override |
| Cleans up resources after the worker thread stops. | |
| bool | should_continue_work () const override |
| Determines whether there is pending work that must complete. | |
| void | on_stop_requested () override |
| Called when stop() is requested. | |
Private Member Functions | |
| uint64_t | next_session_id () |
| Generates a unique session ID for new connections. | |
Private Attributes | |
| uint16_t | port_ |
| TCP port to listen on. | |
| connection_callback | on_connection_ |
| Callback for new connections. | |
| maintenance_callback | on_maintenance_ |
| Optional callback for maintenance tasks. | |
| int | backlog_ {128} |
| Maximum pending connections in listen queue. | |
| std::atomic< uint64_t > | session_id_counter_ {0} |
| Session ID counter for unique connection identification. | |
| std::atomic< bool > | accepting_ {false} |
| Flag indicating if actively accepting connections. | |
| int | listen_socket_ {-1} |
| Listen socket file descriptor (POSIX) | |
Definition at line 80 of file accept_worker.h.
| using kcenon::pacs::network::detail::accept_worker::connection_callback = std::function<void(uint64_t session_id)> |
Callback type for new connection events.
| session_id | Unique identifier for the new session |
Definition at line 90 of file accept_worker.h.
| using kcenon::pacs::network::detail::accept_worker::maintenance_callback = std::function<void()> |
Callback type for periodic maintenance tasks.
Definition at line 93 of file accept_worker.h.
| using kcenon::pacs::network::detail::accept_worker::result_void = common::VoidResult |
Definition at line 86 of file accept_worker.h.
|
explicit |
Constructs an accept_worker with the specified configuration.
| port | The TCP port to listen on for incoming connections |
| on_connection | Callback invoked when a new connection is accepted |
| on_maintenance | Optional callback for periodic maintenance tasks (e.g., idle timeout checks) |
Definition at line 28 of file accept_worker.cpp.
|
override |
Destructor.
Ensures graceful shutdown by calling stop() if still running.
Definition at line 38 of file accept_worker.cpp.
|
delete |
|
delete |
|
overrideprotected |
Cleans up resources after the worker thread stops.
Currently a placeholder. Will close TCP acceptor when network_system integration is complete.
Definition at line 276 of file accept_worker.cpp.
References accepting_, and listen_socket_.
|
overrideprotected |
Initializes resources before the worker thread starts.
Currently a placeholder. Will initialize TCP acceptor when network_system integration is complete.
Definition at line 85 of file accept_worker.cpp.
References accepting_, backlog_, listen_socket_, and port_.
|
overrideprotected |
Main work routine - checks for incoming connections.
This method is called repeatedly by the thread_base framework. Currently implements placeholder logic that:
Future implementation will:
Definition at line 185 of file accept_worker.cpp.
References listen_socket_, next_session_id(), on_connection_, and on_maintenance_.

|
nodiscardnoexcept |
Checks if the worker is actively accepting connections.
Definition at line 65 of file accept_worker.cpp.
References accepting_.
Referenced by to_string().

|
nodiscardnoexcept |
Gets the current backlog setting.
Definition at line 57 of file accept_worker.cpp.
References backlog_.
|
nodiscardprivate |
Generates a unique session ID for new connections.
Definition at line 328 of file accept_worker.cpp.
References session_id_counter_.
Referenced by do_work().

|
overrideprotected |
Called when stop() is requested.
This hook is called from the thread calling stop() before the worker thread actually stops. Currently a no-op as the base class handles waking up the worker thread.
Future implementation will:
Definition at line 307 of file accept_worker.cpp.
References listen_socket_.
|
delete |
|
delete |
|
nodiscardnoexcept |
Gets the configured port number.
Definition at line 53 of file accept_worker.cpp.
References port_.
| void kcenon::pacs::network::detail::accept_worker::set_max_pending_connections | ( | int | backlog | ) |
Sets the maximum number of pending connections in the listen queue.
| backlog | Maximum pending connections (default: 128) |
Definition at line 49 of file accept_worker.cpp.
References backlog_.
|
nodiscardoverrideprotected |
Determines whether there is pending work that must complete.
Returns false because the accept worker has no pending work items that must complete before shutdown. This allows graceful shutdown when stop() is called.
Definition at line 300 of file accept_worker.cpp.
|
nodiscardoverride |
Gets a string representation of the worker state.
Definition at line 69 of file accept_worker.cpp.
References backlog_, is_accepting(), port_, and session_id_counter_.

|
private |
Flag indicating if actively accepting connections.
Definition at line 265 of file accept_worker.h.
Referenced by after_stop(), before_start(), and is_accepting().
|
private |
Maximum pending connections in listen queue.
Definition at line 259 of file accept_worker.h.
Referenced by before_start(), max_pending_connections(), set_max_pending_connections(), and to_string().
|
private |
Listen socket file descriptor (POSIX)
Definition at line 275 of file accept_worker.h.
Referenced by after_stop(), before_start(), do_work(), and on_stop_requested().
|
private |
Callback for new connections.
Definition at line 253 of file accept_worker.h.
Referenced by do_work().
|
private |
Optional callback for maintenance tasks.
Definition at line 256 of file accept_worker.h.
Referenced by do_work().
|
private |
TCP port to listen on.
Definition at line 250 of file accept_worker.h.
Referenced by before_start(), port(), and to_string().
|
private |
Session ID counter for unique connection identification.
Definition at line 262 of file accept_worker.h.
Referenced by next_session_id(), and to_string().