LCOV - code coverage report
Current view: top level - src - FelixServer.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 42 44 95.5 %
Date: 2025-11-29 00:25:29 Functions: 9 11 81.8 %

          Line data    Source code
       1             : #include "felix-server/FelixServer.hpp"
       2             : 
       3             : #include <mutex>
       4             : 
       5             : #include <netio3-backend/EventLoop/AsioEventLoop.hpp>
       6             : #include <netio3-backend/EventLoop/EpollEventLoop.hpp>
       7             : 
       8             : #include "felix-server/Exceptions.hpp"
       9             : 
      10          15 : felix_server::FelixServer::FelixServer(EventLoopType evloop_type) :
      11          15 :   m_event_loop{create_event_loop(evloop_type)},
      12          30 :   m_evloop_thread{[this]() { m_event_loop->run(); }}
      13          15 : {}
      14             : 
      15          15 : felix_server::FelixServer::~FelixServer()
      16             : {
      17          15 :   m_event_loop->stop();
      18          15 :   m_evloop_thread.join();
      19          15 : }
      20             : 
      21           3 : felix_server::BufferedPublisher felix_server::FelixServer::create_buffered_publisher(
      22             :   const BufferedPublisher::Settings& settings,
      23             :   std::span<const std::uint64_t> tags)
      24             : {
      25             :   try {
      26           3 :     std::lock_guard lock(m_mutex);
      27           8 :     return BufferedPublisher{settings, m_event_loop, tags};
      28           5 :   } catch (const BusError& e) {
      29           1 :     throw;
      30           2 :   } catch (const std::exception& e) {
      31           1 :     throw FailedInitPublisher(e);
      32           1 :   }
      33             : }
      34             : 
      35           3 : felix_server::ZeroCopyPublisher felix_server::FelixServer::create_zero_copy_publisher(
      36             :   const ZeroCopyPublisher::Settings& settings,
      37             :   std::span<const std::uint64_t> tags)
      38             : {
      39             :   try {
      40           3 :     std::lock_guard lock(m_mutex);
      41           8 :     return ZeroCopyPublisher{settings, m_event_loop, tags};
      42           5 :   } catch (const BusError& e) {
      43           1 :     throw;
      44           2 :   } catch (const std::exception& e) {
      45           1 :     throw FailedInitPublisher(e);
      46           1 :   }
      47             : }
      48             : 
      49           3 : felix_server::Receiver felix_server::FelixServer::create_receiver(
      50             :   const Receiver::Settings& settings,
      51             :   std::span<const std::uint64_t> tags)
      52             : {
      53             :   try {
      54           3 :     std::lock_guard lock(m_mutex);
      55           8 :     return Receiver{settings, m_event_loop, tags};
      56           5 :   } catch (const BusError& e) {
      57           1 :     throw;
      58           2 :   } catch (const std::exception& e) {
      59           1 :     throw FailedInitReceiver(e);
      60           1 :   }
      61             : }
      62             : 
      63           1 : netio3::EventTimerHandle felix_server::FelixServer::create_timer(const EventLoopCallback& callback)
      64             : {
      65           2 :   return m_event_loop->create_timer([callback](int) { callback(); });
      66             : }
      67             : 
      68           2 : netio3::EventSignalHandle felix_server::FelixServer::create_signal(
      69             :   const EventLoopCallback& callback,
      70             :   bool semaphore)
      71             : {
      72           4 :   return m_event_loop->create_signal([callback](int) { callback(); }, semaphore);
      73             : }
      74             : 
      75          15 : std::shared_ptr<netio3::BaseEventLoop> felix_server::FelixServer::create_event_loop(
      76             :   EventLoopType evloop_type)
      77             : {
      78          15 :   switch (evloop_type) {
      79           1 :   case EventLoopType::asio:
      80           1 :     return std::make_shared<netio3::AsioEventLoop>();
      81          14 :   case EventLoopType::epoll:
      82          14 :     return std::make_shared<netio3::EpollEventLoop>();
      83           0 :   default:
      84           0 :     throw std::logic_error("Invalid EventLoopType");
      85             :   }
      86             : }

Generated by: LCOV version 1.0