LCOV - code coverage report
Current view: top level - corosio/detail - local_stream_service.hpp (source / functions) Coverage Total Hit Missed
Test: coverage_remapped.info Lines: 100.0 % 2 2
Test Date: 2026-04-13 22:45:57 Functions: 66.7 % 3 2 1

           TLA  Line data    Source code
       1                 : //
       2                 : // Copyright (c) 2026 Michael Vandeberg
       3                 : //
       4                 : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5                 : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6                 : //
       7                 : // Official repository: https://github.com/cppalliance/corosio
       8                 : //
       9                 : 
      10                 : #ifndef BOOST_COROSIO_DETAIL_LOCAL_STREAM_SERVICE_HPP
      11                 : #define BOOST_COROSIO_DETAIL_LOCAL_STREAM_SERVICE_HPP
      12                 : 
      13                 : #include <boost/corosio/detail/config.hpp>
      14                 : #include <boost/corosio/local_stream_socket.hpp>
      15                 : #include <boost/capy/ex/execution_context.hpp>
      16                 : #include <system_error>
      17                 : 
      18                 : namespace boost::corosio::detail {
      19                 : 
      20                 : /* Abstract local stream service base class.
      21                 : 
      22                 :    Concrete implementations (epoll, select, kqueue) inherit from
      23                 :    this class and provide platform-specific stream socket operations
      24                 :    for Unix domain sockets. The context constructor installs
      25                 :    whichever backend via make_service, and local_stream_socket.cpp
      26                 :    retrieves it via use_service<local_stream_service>().
      27                 : */
      28                 : class BOOST_COROSIO_DECL local_stream_service
      29                 :     : public capy::execution_context::service
      30                 :     , public io_object::io_service
      31                 : {
      32                 : public:
      33                 :     /// Identifies this service for execution_context lookup.
      34                 :     using key_type = local_stream_service;
      35                 : 
      36                 :     /** Open a local (Unix domain) stream socket.
      37                 : 
      38                 :         Creates a socket and associates it with the platform
      39                 :         I/O backend (reactor or IOCP).
      40                 : 
      41                 :         @param impl The socket implementation to open.
      42                 :         @param family Address family for local IPC.
      43                 :         @param type Socket type for stream sockets.
      44                 :         @param protocol Protocol number (typically 0).
      45                 :         @return Error code on failure, empty on success.
      46                 :     */
      47                 :     virtual std::error_code open_socket(
      48                 :         local_stream_socket::implementation& impl,
      49                 :         int family,
      50                 :         int type,
      51                 :         int protocol) = 0;
      52                 : 
      53                 :     /** Assign an existing native socket handle to a socket.
      54                 : 
      55                 :         Adopts a pre-created socket handle (e.g. from a
      56                 :         platform-specific pair creation API). On success the
      57                 :         impl takes ownership and will close the handle. On
      58                 :         failure the caller retains ownership and must close
      59                 :         it. On platforms that do not support handle adoption,
      60                 :         returns @c operation_not_supported.
      61                 : 
      62                 :         @param impl The socket implementation to assign to.
      63                 :         @param fd The native socket handle to adopt.
      64                 :         @return Error code on failure, empty on success.
      65                 :     */
      66                 :     virtual std::error_code assign_socket(
      67                 :         local_stream_socket::implementation& impl,
      68                 :         int fd) = 0;
      69                 : 
      70                 : protected:
      71 HIT         583 :     local_stream_service() = default;
      72             583 :     ~local_stream_service() override = default;
      73                 : };
      74                 : 
      75                 : } // namespace boost::corosio::detail
      76                 : 
      77                 : #endif // BOOST_COROSIO_DETAIL_LOCAL_STREAM_SERVICE_HPP
        

Generated by: LCOV version 2.3