Start the subsystem's processing/event loops.
Begins active processing. After this call, the subsystem should be actively responding to callbacks and processing data according to its domain requirements.
66{
69 "Cannot start NetworkSubsystem: not initialized");
70 return;
71 }
72
74 return;
75 }
76
77 {
79 for (
auto& [transport, backend] :
m_backends) {
80 backend->start();
81 }
82 }
83
84 m_work_guard = std::make_unique<asio::executor_work_guard<asio::io_context::executor_type>>(
86
87#if MAYAFLUX_USE_JTHREAD
88 m_io_thread = std::jthread([
this](
const std::stop_token& token) {
89 while (!token.stop_requested()) {
90 try {
91 m_io_context->run();
92 break;
93 } catch (const std::exception& e) {
95 "IO context exception: {}", e.what());
96 }
97 }
98
100 "Network IO thread exiting");
101 });
102#else
106 try {
107 m_io_context->run();
108 break;
109 } catch (const std::exception& e) {
111 "IO context exception: {}", e.what());
112 }
113 }
114
116 "Network IO thread exiting");
117 });
118#endif
119
121
123 "Network Subsystem started");
124}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::unique_ptr< asio::io_context > m_io_context
std::shared_mutex m_backends_mutex
std::unique_ptr< asio::executor_work_guard< asio::io_context::executor_type > > m_work_guard
std::atomic< bool > m_ready
std::atomic< bool > m_io_stop_requested
std::unordered_map< NetworkTransport, std::unique_ptr< INetworkBackend > > m_backends
std::atomic< bool > m_running
@ Init
Engine/subsystem initialization.
@ Networking
Network operations (data transfer, protocol handling)
@ Core
Core engine, backend, subsystems.