MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ stop()

void MayaFlux::Core::TCPBackend::stop ( )
overridevirtual

Stop receive threads without releasing resources.

Endpoints remain valid. Pending sends complete. Receive callbacks cease until start() is called again.

Implements MayaFlux::Core::INetworkBackend.

Definition at line 55 of file TCPBackend.cpp.

56{
57 if (!m_running.load()) {
58 return;
59 }
60
61 m_running.store(false);
62
63 {
64 std::shared_lock lock(m_connections_mutex);
65 for (auto& [id, conn] : m_connections) {
66 asio::error_code ec;
67
68 if (conn->socket.close(ec)) {
70 "Error closing TCP connection {}: {}", id, ec.message());
71 }
72
73 if (conn->reconnect_timer) {
74 conn->reconnect_timer->cancel();
75 }
76 }
77 }
78
79 {
80 std::shared_lock lock(m_listeners_mutex);
81 for (auto& [id, listener] : m_listeners) {
82 asio::error_code ec;
83 if (!listener->acceptor.close(ec)) {
85 "Error closing TCP listener {}: {}", id, ec.message());
86 }
87 }
88 }
89
91 "TCP backend stopped");
92}
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::atomic< bool > m_running
std::unordered_map< uint64_t, std::unique_ptr< ConnectionState > > m_connections
std::shared_mutex m_listeners_mutex
std::unordered_map< uint64_t, std::unique_ptr< ListenerState > > m_listeners
std::shared_mutex m_connections_mutex
@ Shutdown
Engine/subsystem shutdown and cleanup.
@ NetworkBackend
Network transport backend (UDP, TCP, SHM)
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, m_connections, m_connections_mutex, m_listeners, m_listeners_mutex, m_running, MF_DEBUG, MF_WARN, MayaFlux::Journal::NetworkBackend, and MayaFlux::Journal::Shutdown.

Referenced by shutdown().

+ Here is the caller graph for this function: