/
Shymer123
/
LumenServer
Обзор
Документация
Войти
/
Shymer123
/
LumenServer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Server/SourceFiles/Core/Runtime.cpp
72 строки
2 KB
Shymer123
Initial commit: LumenServer
20 июн 2026, 12:43
20 июн 2026, 12:43
173f14c
Код
Авторство
О чём код?
#include "Runtime.h" #include "Network/TcpServer.h" #include "Infrastructure/ThreadPoolManager.h" #include <iostream> namespace Core { Runtime::Runtime(Core::RuntimeContext& context) : m_context(context), m_threadPoolManager(context.threadPoolManager()) {} Runtime::~Runtime() { stop(); } void Runtime::start() { std::cout << "[Runtime] Starting server..." << std::endl; m_threadPoolManager->start(); auto& netCfg = m_context.settings().serverSettings(); m_tcpServer = std::make_unique<Network::TcpServer>(m_threadPoolManager->io(), netCfg.port(), *m_context.router()); m_tcpServer->startAccept(); auto& io = m_threadPoolManager->io(); m_signals = std::make_unique<boost::asio::signal_set>(io, SIGINT, SIGTERM); m_signals->async_wait([this](const boost::system::error_code&, int) { std::cout << "\n[Runtime] Signal caught — stopping server..." << std::endl; if(m_exitMutex && m_exitCv) { std::lock_guard<std::mutex> lock(*m_exitMutex); m_exitCv->notify_all(); } }); } void Runtime::stop() { if(m_stopped) return; m_stopped = true; if(m_signals) { boost::system::error_code ec; m_signals->cancel(ec); m_signals.reset(); } if(m_tcpServer) { m_tcpServer->stop(); } if(m_threadPoolManager) { m_threadPoolManager->stop(); } if(m_tcpServer) { m_tcpServer.reset(); } } } // namespace Core