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

◆ start()

void MayaFlux::Core::NetworkSubsystem::start ( )
overridevirtual

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.

Implements MayaFlux::Core::ISubsystem.

Definition at line 65 of file NetworkSubsystem.cpp.

66{
67 if (!m_ready.load()) {
69 "Cannot start NetworkSubsystem: not initialized");
70 return;
71 }
72
73 if (m_running.load()) {
74 return;
75 }
76
77 {
78 std::shared_lock lock(m_backends_mutex);
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>>(
85 m_io_context->get_executor());
86
87 m_io_thread = std::jthread([this](const std::stop_token& token) {
88 while (!token.stop_requested()) {
89 try {
90 m_io_context->run();
91 break;
92 } catch (const std::exception& e) {
94 "IO context exception: {}", e.what());
95 }
96 }
97
99 "Network IO thread exiting");
100 });
101
102 m_running.store(true);
103
105 "Network Subsystem started");
106}
#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::unique_ptr< asio::executor_work_guard< asio::io_context::executor_type > > m_work_guard
std::unordered_map< NetworkTransport, std::unique_ptr< INetworkBackend > > m_backends
@ Init
Engine/subsystem initialization.
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Journal::Init, m_backends, m_backends_mutex, m_io_context, m_io_thread, m_ready, m_running, m_work_guard, MF_DEBUG, and MF_ERROR.