MayaFlux 0.4.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 51 of file TCPBackend.cpp.

52{
53 if (!m_running.load()) {
54 return;
55 }
56
57 m_running.store(false);
58
59 {
60 std::shared_lock lock(m_connections_mutex);
61 for (auto& [id, conn] : m_connections) {
62 asio::error_code ec;
63
64 if (conn->socket.close(ec)) {
66 "Error closing TCP connection {}: {}", id, ec.message());
67 }
68
69 if (conn->reconnect_timer) {
70 conn->reconnect_timer->cancel();
71 }
72 }
73 }
74
75 {
76 std::shared_lock lock(m_listeners_mutex);
77 for (auto& [id, listener] : m_listeners) {
78 asio::error_code ec;
79 if (!listener->acceptor.close(ec)) {
81 "Error closing TCP listener {}: {}", id, ec.message());
82 }
83 }
84 }
85
87 "TCP backend stopped");
88}
#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: